public async Task <IResult> UpdateAsync(long constraintId, UpdateConstraintModel updateConstraintModel) { var validation = new UpdateConstraintModelValidator().Valid(updateConstraintModel); if (!validation.Success) { return(new ErrorResult(validation.Message)); } var constraintEntity = await ConstraintRepository.SelectAsync(constraintId); var nullObjectValidation = new NullObjectValidation <ConstraintEntity>().Valid(constraintEntity); if (!nullObjectValidation.Success) { return(new ErrorResult(nullObjectValidation.Message)); } var constraintDomain = ConstraintDomainFactory.Create(constraintEntity); constraintDomain.Update(updateConstraintModel); constraintEntity = constraintDomain.Map <ConstraintEntity>(); await ConstraintRepository.UpdateAsync(constraintEntity, constraintEntity.ConstraintId); await DatabaseUnitOfWork.SaveChangesAsync(); return(new SuccessResult()); }
public void Update(UpdateConstraintModel updateConstraintModel) { Title = updateConstraintModel.Title; Description = updateConstraintModel.Description; IsFreeDay = updateConstraintModel.IsFreeDay; IsActive = updateConstraintModel.IsActive; WeeklyHour = updateConstraintModel.WeeklyHour; EducationType = updateConstraintModel.EducationType; UserId = updateConstraintModel.UserId; UpdatedDate = DateTime.Now; StartTime = updateConstraintModel.StartTime; EndTime = updateConstraintModel.EndTime; }
public static ConstraintDomain Create(UpdateConstraintModel updateConstraintModel) { return(new ConstraintDomain( updateConstraintModel.Title, updateConstraintModel.Description, updateConstraintModel.IsFreeDay, updateConstraintModel.IsActive, updateConstraintModel.WeeklyHour, updateConstraintModel.EducationType, updateConstraintModel.UserId, updateConstraintModel.StartTime, updateConstraintModel.EndTime )); }
public async Task <IActionResult> UpdateAsync(long constraintId, UpdateConstraintModel updateConstraintModel) { var result = await ConstraintService.UpdateAsync(constraintId, updateConstraintModel); return(new ActionIResult(result)); }