Ejemplo n.º 1
0
        public int Update(AdminUpdateCategoryWrapper wrapper)
        {
            try
            {
                var entity = _unitOfWork.CategoryRepository.Get(wrapper.CategoryId);

                if (entity == null)
                {
                    throw  new ApplicationException($"Category Id {wrapper.CategoryId} not found");
                }

                entity.LastUpdatedBy   = wrapper.UserId;
                entity.LastUpdatedDate = DateTime.Now;

                entity.Name             = wrapper.Name;
                entity.UrlSlug          = wrapper.UrlSlug;
                entity.ParentCategoryId = wrapper.ParentCategoryId;

                _unitOfWork.CategoryRepository.Update(entity);
                return(_unitOfWork.SaveChanges());
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 public Task <int> UpdateAsync(AdminUpdateCategoryWrapper wrapper)
 {
     return(Task.Run(() => Update(wrapper)));
 }