public async Task <CoachResponse> UpdateAsync(int id, Coach coach) { var existingCoach = await _coachRepository.FindByIdAsync(id); if (existingCoach == null) { return(new CoachResponse("Coach not found.")); } existingCoach.CoachFirstName = coach.CoachFirstName; existingCoach.CoachLastName = coach.CoachLastName; existingCoach.CoachFatherName = coach.CoachFatherName; existingCoach.CoachMotherName = coach.CoachMotherName; existingCoach.PhoneNumber = coach.PhoneNumber; existingCoach.Email = coach.Email; existingCoach.DateBirth = coach.DateBirth; existingCoach.PlaceBirth = coach.PlaceBirth; existingCoach.Details = coach.Details; existingCoach.FieldID = coach.FieldID; existingCoach.Organization = coach.Organization; existingCoach.IsStudent = coach.IsStudent; existingCoach.SpecializationID = coach.SpecializationID; try { _coachRepository.Update(existingCoach); await _unitOfWork.CompleteAsync(); return(new CoachResponse(existingCoach)); } catch (Exception ex) { return(new CoachResponse($"An error occurred when updating the Coach: {ex.Message}")); } }