public async Task <Diver> EditDiverAsync(int diverId, EditDiverModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var existing = await _diverRepository.GetAsync(diverId); if (existing == null) { throw new NotFoundException("Водолаз не найден."); } existing.LastName = model.LastName; existing.FirstName = model.FirstName; existing.MiddleName = model.MiddleName; existing.PhotoUrl = model.PhotoUrl; existing.BirthDate = model.BirthDate; existing.RescueStationId = model.RescueStationId; existing.MedicalExaminationDate = model.MedicalExaminationDate; existing.Address = model.Address; existing.Qualification = model.Qualification; existing.PersonalBookNumber = model.PersonalBookNumber; existing.PersonalBookIssueDate = model.PersonalBookIssueDate; existing.PersonalBookProtocolNumber = model.PersonalBookProtocolNumber; var updated = await _diverRepository.UpdateAsync(existing); var hours = await SetWorkingHours(updated.DiverId, model.WorkingTime); var diver = _mapper.Map <Diver>(updated); diver.WorkingTime = hours; return(diver); }