public async Task <Specialty> Update(Specialty speciality) { List <Task> tasks = new List <Task>(); var facultyIdExists = _facultyRepository.GetById(speciality.FacultyId); tasks.Add(facultyIdExists); var idExists = _specialtyRepository.GetById(speciality.Id); tasks.Add(idExists); var uniqueName = _specialtyRepository.GetByName(speciality.Name); tasks.Add(uniqueName); var lectorIdExists = _lectorRepository.GetById(speciality.LectorId) != null; await Task.WhenAll(tasks); if (facultyIdExists.Result != null && lectorIdExists && idExists.Result != null && uniqueName.Result == null) { return(await _specialtyRepository.Update(speciality)); } else { throw new Exception(); } }
public Speciality Update(ChangeSpecialityCommand command) { var speciality = _repository.GetOne(command.Id); if (!string.IsNullOrEmpty(command.Name)) { speciality.ChangeName(command.Name); } if (!string.IsNullOrEmpty(command.Description)) { speciality.ChangeDescription(command.Description); } _repository.Update(speciality); if (Commit()) { return(speciality); } return(null); }
public void UpdateSpeciality(Speciality speciality, string userName) { speciality.DateUpdated = DateTime.Now; speciality.UpdatedByUserName = userName; _repository.Update(speciality); }
Speciality ISpecialtyService.Update(Speciality speciality) { _specialtyRepository.Update(speciality); return(_specialtyRepository.GetById(speciality.Id)); }