Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void UpdateSpeciality(Speciality speciality, string userName)
 {
     speciality.DateUpdated       = DateTime.Now;
     speciality.UpdatedByUserName = userName;
     _repository.Update(speciality);
 }
Exemplo n.º 4
0
 Speciality ISpecialtyService.Update(Speciality speciality)
 {
     _specialtyRepository.Update(speciality);
     return(_specialtyRepository.GetById(speciality.Id));
 }