52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Core.Entities;
|
|
using Application.Endpoints.Doctors.Login;
|
|
using Application.Services.Database;
|
|
|
|
namespace HealthcareManager.API.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class DoctorsController : ControllerBase
|
|
{
|
|
private readonly IDoctorRepository _database;
|
|
|
|
public DoctorsController(IDoctorRepository database)
|
|
{
|
|
_database = database ?? throw new ArgumentNullException(nameof(database));
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
public async Task<ActionResult<Doctor>> GetDoctor(int id)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult<Doctor>> Login(DoctorLoginDTO doctor)
|
|
{
|
|
var handler = new DoctorLoginHandler(_database);
|
|
var response = handler.Handle(doctor).Result;
|
|
|
|
if(!response.Success)
|
|
{
|
|
return Unauthorized(response.Message);
|
|
}
|
|
|
|
return Ok(response.Message);
|
|
}
|
|
|
|
[HttpPut("{id}")]
|
|
public async Task<IActionResult> PutDoctor(int id, Doctor doctor)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
[HttpDelete("{id}")]
|
|
public async Task<IActionResult> DeleteDoctor(int id)
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
}
|