API Traieste
This commit is contained in:
@@ -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}")]
|
||||
|
||||
Reference in New Issue
Block a user