public static UpdateClinicReqeustMessage ToUpdateClinicReqeustMessage(this ClinicUpdateDto dto) { return(new UpdateClinicReqeustMessage { ClinicId = dto.Id, Name = dto.Name }); }
public static Clinic ToClinic(this ClinicUpdateDto dto, Clinic clinic) { return(new Clinic() { Id = dto.Id, Name = dto.Name }); }
public static void Parse(this Clinic clinic, ClinicUpdateDto dto) { if (clinic.Id != dto.Id) { throw new Exception("ClinicUpdateDto parse - Model and dto should have the same id"); } clinic.Name = dto.Name; }
public async Task <IActionResult> UpdateClinic([FromBody] ClinicUpdateDto clinic) { return(await ActionHandle(async() => { var createdClinic = await clinicService.UpdateClinic(clinic); if (createdClinic == false) { return BadRequest("Unable to update clinic."); } return Ok(createdClinic); })); }
public async Task <ClinicDetailDto> UpdateClinic(ClinicUpdateDto dto) { var clinic = await clinicRepository.Get(dto.Id); if (clinic == null) { throw new Exception("Unable to find clinic to update"); } clinic.Parse(dto); await clinicRepository.SaveChangesAsync(); return(clinic.ToClinicDetailDto()); }
public async Task <bool> UpdateClinic(ClinicUpdateDto clinicToUpdate) { var result = await client.UpdateClinicAsync(clinicToUpdate.ToUpdateClinicReqeustMessage()); return(result.Result); }