예제 #1
0
 public async Task UpdateEntityCategoryTransactionAsync(EntityCategory entity,
                                                        UpdateEntityCategoryModel model)
 {
     if (model.NewEntityCategoryContents != null)
     {
         CreateEntityCategoryContents(model.NewEntityCategoryContents, entity);
     }
     if (model.UpdateEntityCategoryContents != null)
     {
         UpdateEntityCategoryContents(model.UpdateEntityCategoryContents, entity.Id);
     }
     if (model.DeleteEntityCategoryContentLangs != null)
     {
         await DeleteContentsOfCategoryAsync(model.DeleteEntityCategoryContentLangs, entity.Id);
     }
 }
        public async Task <IActionResult> Update(int id, UpdateEntityCategoryModel model)
        {
            var entity = _service.EntityCategories.Id(id).FirstOrDefault();

            if (entity == null)
            {
                return(NotFound(new AppResultBuilder().NotFound()));
            }
            var validationResult = _service.ValidateUpdateEntityCategory(User, entity, model);

            if (!validationResult.Valid)
            {
                return(BadRequest(validationResult.Result));
            }
            using (var trans = context.Database.BeginTransaction())
            {
                await _service.UpdateEntityCategoryTransactionAsync(entity, model);

                context.SaveChanges();
                trans.Commit();
            }
            return(NoContent());
        }
예제 #3
0
 public ValidationResult ValidateUpdateEntityCategory(ClaimsPrincipal principal,
                                                      EntityCategory entity, UpdateEntityCategoryModel model)
 {
     return(ValidationResult.Pass());
 }