API Traieste

This commit is contained in:
andrei-mihnea-cerbu
2024-04-04 19:21:03 +03:00
parent 22f171b560
commit 1206db9321
104 changed files with 359 additions and 366 deletions
+16 -10
View File
@@ -1,9 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Core.Entities;
using Application.Endpoints.Doctors.Login;
using Application.Services.Database;
namespace HealthcareManager.API.Controllers
{
@@ -11,11 +9,11 @@ namespace HealthcareManager.API.Controllers
[Route("api/[controller]")]
public class DoctorsController : ControllerBase
{
private readonly HealthcareManagerContext _context;
private readonly IDoctorRepository _database;
public DoctorsController(HealthcareManagerContext context)
public DoctorsController(IDoctorRepository database)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_database = database ?? throw new ArgumentNullException(nameof(database));
}
[HttpGet("{id}")]
@@ -25,9 +23,17 @@ namespace HealthcareManager.API.Controllers
}
[HttpPost]
public async Task<ActionResult<Doctor>> PostDoctor(Doctor doctor)
public async Task<ActionResult<Doctor>> Login(DoctorLoginDTO doctor)
{
return NotFound();
var handler = new DoctorLoginHandler(_database);
var response = handler.Handle(doctor).Result;
if(!response.Success)
{
return Unauthorized(response.Message);
}
return Ok(response.Message);
}
[HttpPut("{id}")]