diff --git a/src/Backend/Controllers/AboutController.cs b/src/Backend/Controllers/AboutController.cs index fc0a4fc..d1f9069 100644 --- a/src/Backend/Controllers/AboutController.cs +++ b/src/Backend/Controllers/AboutController.cs @@ -19,5 +19,12 @@ public string Get() { return _localizer["About Title"]; } + + [HttpGet("GetResource")] + public IActionResult GetResource() + { + //error 404 not found + return NotFound(_localizer["Resource not found"].Value); + } } } \ No newline at end of file diff --git a/src/Backend/Controllers/UserController.cs b/src/Backend/Controllers/UserController.cs new file mode 100644 index 0000000..4dfd634 --- /dev/null +++ b/src/Backend/Controllers/UserController.cs @@ -0,0 +1,22 @@ +using Backend.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Backend.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class UserController : ControllerBase + { + [HttpPost] + public IActionResult Post([FromBody] User user) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + return Ok(); + } + } +} diff --git a/src/Backend/Models/User.cs b/src/Backend/Models/User.cs new file mode 100644 index 0000000..2a26003 --- /dev/null +++ b/src/Backend/Models/User.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace Backend.Models +{ + public class User + { + [Required(ErrorMessage = "The Name field is required.")] + [StringLength(50, ErrorMessage = "The Name field cannot be more than 50 characters.")] + public string Name { get; set; } + + [Required(ErrorMessage = "The Email field is required.")] + [EmailAddress(ErrorMessage = "The Email field does not have a valid format.")] + public string Email { get; set; } + } +} diff --git a/src/Backend/Program.cs b/src/Backend/Program.cs index 17e1af8..4c7f692 100644 --- a/src/Backend/Program.cs +++ b/src/Backend/Program.cs @@ -1,3 +1,4 @@ +using Backend; using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization.Routing; @@ -5,7 +6,12 @@ // Add services to the container. -builder.Services.AddControllers(); +builder.Services.AddControllers() + .AddDataAnnotationsLocalization(options => { + options.DataAnnotationLocalizerProvider = (type, factory) => + factory.Create(typeof(SharedResource)); + }); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); @@ -21,11 +27,11 @@ .AddSupportedUICultures(SupportedCultures) .RequestCultureProviders = new List { - //new AcceptLanguageHeaderRequestCultureProvider(), + new AcceptLanguageHeaderRequestCultureProvider(), //new QueryStringRequestCultureProvider(), //new CookieRequestCultureProvider(), //new RouteDataRequestCultureProvider(), - new CustomRequestCultureProvider(async context => + /*new CustomRequestCultureProvider(async context => { // Aquí debes implementar tu lógica para determinar la cultura basada en el contexto de la solicitud. // Puedes leer cookies, cabeceras, etc. para decidir la cultura. @@ -34,7 +40,7 @@ string culture = "es-ES"; return new ProviderCultureResult(culture); - }) + })*/ }; }); diff --git a/src/Backend/Resources/Controllers/AboutController.en-US.resx b/src/Backend/Resources/Controllers/AboutController.en-US.resx index 3d51f96..64bddc2 100644 --- a/src/Backend/Resources/Controllers/AboutController.en-US.resx +++ b/src/Backend/Resources/Controllers/AboutController.en-US.resx @@ -120,4 +120,7 @@ About us + + Resource not found + \ No newline at end of file diff --git a/src/Backend/Resources/Controllers/AboutController.en.resx b/src/Backend/Resources/Controllers/AboutController.en.resx index 3d51f96..64bddc2 100644 --- a/src/Backend/Resources/Controllers/AboutController.en.resx +++ b/src/Backend/Resources/Controllers/AboutController.en.resx @@ -120,4 +120,7 @@ About us + + Resource not found + \ No newline at end of file diff --git a/src/Backend/Resources/Controllers/AboutController.es-ES.resx b/src/Backend/Resources/Controllers/AboutController.es-ES.resx index e6d69b1..36ee74c 100644 --- a/src/Backend/Resources/Controllers/AboutController.es-ES.resx +++ b/src/Backend/Resources/Controllers/AboutController.es-ES.resx @@ -120,4 +120,7 @@ Sobre nosotros + + Recurso no encontrado + \ No newline at end of file diff --git a/src/Backend/Resources/Controllers/AboutController.es.resx b/src/Backend/Resources/Controllers/AboutController.es.resx index e6d69b1..36ee74c 100644 --- a/src/Backend/Resources/Controllers/AboutController.es.resx +++ b/src/Backend/Resources/Controllers/AboutController.es.resx @@ -120,4 +120,7 @@ Sobre nosotros + + Recurso no encontrado + \ No newline at end of file diff --git a/src/Backend/Resources/SharedResource.en-US.resx b/src/Backend/Resources/SharedResource.en-US.resx index 3f5df82..95c2e9d 100644 --- a/src/Backend/Resources/SharedResource.en-US.resx +++ b/src/Backend/Resources/SharedResource.en-US.resx @@ -117,6 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + The Email field does not have a valid format. + + + The Email field is required. + + + The Name field cannot be more than 50 characters. + + + The Name field is required. + Your application description page. diff --git a/src/Backend/Resources/SharedResource.en.resx b/src/Backend/Resources/SharedResource.en.resx index 3f5df82..95c2e9d 100644 --- a/src/Backend/Resources/SharedResource.en.resx +++ b/src/Backend/Resources/SharedResource.en.resx @@ -117,6 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + The Email field does not have a valid format. + + + The Email field is required. + + + The Name field cannot be more than 50 characters. + + + The Name field is required. + Your application description page. diff --git a/src/Backend/Resources/SharedResource.es-ES.resx b/src/Backend/Resources/SharedResource.es-ES.resx index 7efd338..479dc17 100644 --- a/src/Backend/Resources/SharedResource.es-ES.resx +++ b/src/Backend/Resources/SharedResource.es-ES.resx @@ -117,6 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + El campo Email no tiene un formato válido. + + + El campo Email es obligatorio. + + + El campo Nombre no puede tener más de 50 caracteres. + + + El campo Nombre es obligatorio. + La página de descripción de su aplicación. diff --git a/src/Backend/Resources/SharedResource.es.resx b/src/Backend/Resources/SharedResource.es.resx index 7efd338..479dc17 100644 --- a/src/Backend/Resources/SharedResource.es.resx +++ b/src/Backend/Resources/SharedResource.es.resx @@ -117,6 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + El campo Email no tiene un formato válido. + + + El campo Email es obligatorio. + + + El campo Nombre no puede tener más de 50 caracteres. + + + El campo Nombre es obligatorio. + La página de descripción de su aplicación.