From f9a680c554b61b549900942e2b6e0f1bfe8fa7db Mon Sep 17 00:00:00 2001 From: shept Date: Tue, 25 Mar 2025 22:22:57 +0500 Subject: [PATCH] started api work --- .../Controllers/AuthController.cs | 15 +++++++++++++++ .../SurveyBackend.API/DTOs/UserLoginDTO.cs | 4 ++-- SurveyBackend/SurveyBackend.API/Program.cs | 6 ++++-- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs diff --git a/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs b/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs new file mode 100644 index 0000000..94f1cb4 --- /dev/null +++ b/SurveyBackend/SurveyBackend.API/Controllers/AuthController.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; +using SurveyBackend.DTOs; + +namespace SurveyBackend.Controllers; + +[ApiController] +[Route("[controller]")] +public class AuthController : ControllerBase +{ + [HttpPost("login")] + public async Task GetToken([FromBody] UserLoginDTO loginData) + { + return Ok(); + } +} \ No newline at end of file diff --git a/SurveyBackend/SurveyBackend.API/DTOs/UserLoginDTO.cs b/SurveyBackend/SurveyBackend.API/DTOs/UserLoginDTO.cs index a6125a7..9dc2510 100644 --- a/SurveyBackend/SurveyBackend.API/DTOs/UserLoginDTO.cs +++ b/SurveyBackend/SurveyBackend.API/DTOs/UserLoginDTO.cs @@ -2,6 +2,6 @@ namespace SurveyBackend.DTOs; public record UserLoginDTO { - public string Email { get; set; } - public string Password { get; set; } + public required string Email { get; set; } + public required string Password { get; set; } } \ No newline at end of file diff --git a/SurveyBackend/SurveyBackend.API/Program.cs b/SurveyBackend/SurveyBackend.API/Program.cs index 3a98e82..e7d098c 100644 --- a/SurveyBackend/SurveyBackend.API/Program.cs +++ b/SurveyBackend/SurveyBackend.API/Program.cs @@ -8,6 +8,8 @@ public class Program // Add services to the container. builder.Services.AddAuthorization(); + + builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); @@ -22,10 +24,10 @@ public class Program app.UseSwaggerUI(); } - app.UseHttpsRedirection(); - app.UseAuthorization(); + app.MapControllers(); + app.Run(); } } \ No newline at end of file