public static FacultyDomain Create(UpdateFacultyModel updateFacultyModel)
 {
     return(new FacultyDomain(
                updateFacultyModel.Title,
                updateFacultyModel.FacultyCode
                ));
 }
        public async Task <IResult> UpdateAsync(long facultyId, UpdateFacultyModel updateFacultyModel)
        {
            var validation = new FacultyModelValidator().Valid(updateFacultyModel);

            if (!validation.Success)
            {
                return(new ErrorDataResult <long>(validation.Message));
            }

            var facultyEntity = await FacultyRepository.SelectAsync(facultyId);

            var nullObjectValidation = new NullObjectValidation <FacultyEntity>().Valid(facultyEntity);

            if (!nullObjectValidation.Success)
            {
                return(new ErrorResult(nullObjectValidation.Message));
            }

            var facultyDomain = FacultyDomainFactory.Create(facultyEntity);

            facultyDomain.Update(updateFacultyModel);

            facultyEntity = facultyDomain.Map <FacultyEntity>();

            facultyEntity.FacultyId = facultyId;

            await FacultyRepository.UpdateAsync(facultyEntity, facultyEntity.FacultyId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }
Ejemplo n.º 3
0
        public async Task Update(UpdateFacultyModel model)
        {
            var university = await _repository.GetByIdWithFaculties(model.UniversityId);

            university.UpdateFaculty(model.Id, _mapper.Map<Faculty>(model));

            _repository.Update(university);

            await _repository.SaveChanges();
        }
Ejemplo n.º 4
0
            public async Task <IActionResult> Update([FromRoute] Guid universityId, [FromRoute] Guid facultyId, [FromBody] UpdateFacultyModel model)
            {
                model.Id           = facultyId;
                model.UniversityId = universityId;
                await _facultyService.Update(model);

                return(NoContent());
            }
Ejemplo n.º 5
0
 public void Update(UpdateFacultyModel updateFacultyModel)
 {
     Title       = updateFacultyModel.Title;
     FacultyCode = updateFacultyModel.FacultyCode;
     UpdatedDate = DateTime.Now;
 }
        public async Task <IActionResult> UpdateAsync(long facultyId, UpdateFacultyModel updateFacultyModel)
        {
            var result = await FacultyService.UpdateAsync(facultyId, updateFacultyModel);

            return(new ActionIResult(result));
        }