public async Task <string> Edit([FromBody] EditDoctorModel editDoctorModel) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var doctor = await DoctorFacade.GetDoctorByUsernameAsync(editDoctorModel.Username); if (doctor == null) { throw new HttpResponseException(HttpStatusCode.NotModified); } var doctorDto = doctor; doctorDto.Id = doctor.Id; doctorDto.Name = editDoctorModel.Name.IsNullOrEmpty() ? null : editDoctorModel.Name; doctorDto.Surname = editDoctorModel.Surname.IsNullOrEmpty() ? null : editDoctorModel.Surname; if (editDoctorModel.Specialization != null) { Specialization spec; var succ = Specialization.TryParse(editDoctorModel.Specialization, out spec); if (!succ) { throw new HttpResponseException(HttpStatusCode.NotModified); } doctorDto.Specialization = spec; } var succ1 = await DoctorFacade.EditDoctorAsync(doctorDto); if (!succ1) { throw new HttpResponseException(HttpStatusCode.NotModified); } return($"Edited DOCTOR with username = {editDoctorModel.Username}"); }