public async Task <Result> Delete(PatientsDto patient) { var data = _mapper.Map <Patient>(patient); var result = await _dbContext.PatientRepository.Delete(data); return(result); }
public async Task <IActionResult> PartiallyUpdate([FromBody] PatientsDto patchDoc) { if (patchDoc == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _patientBusness.Update(patchDoc); return(NoContent()); }
public async Task <IActionResult> Insert([FromBody] PatientsDto patient) { if (patient == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _patientBusness.Insert(patient); return(CreatedAtRoute("GetById", new { id = result.Id }, patient)); }
public PatientsDto PostPatients(PatientsDto patientsDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var patient = Mapper.Map <PatientsDto, Patients>(patientsDto); _context.Patients.Add(patient); _context.SaveChanges(); patientsDto.PatientId = patient.PatientId; return(patientsDto); }
public void PutPatients(int userId, PatientsDto patientsDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var patient = _context.Patients.SingleOrDefault(p => p.UserId == userId); if (patient == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } Mapper.Map(patientsDto, patient); _context.SaveChanges(); }
public async Task <IActionResult> Update(int id, [FromBody] PatientsDto patient) { if (!await _patientBusness.CheckIfExist(id)) { return(BadRequest()); } if (patient == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _patientBusness.Update(patient); return(NoContent()); }