Esempio n. 1
0
        public CategoryEditModels CreateCategory(CategoryEditModels model, out string message)
        {
            var ship = _CategoryRepository.getCategory(model.CategoryId, model.CategoryName);

            if (ship != null)
            {
                message = Constant.CategoryIsExist;
                return(null);
            }
            var CreateCategory = _CategoryRepository.Insert(model.MapToEditEntity());

            UnitOfwork.SaveChanges();
            if (CreateCategory == null)
            {
                message = Constant.CreateFail;
                return(null);
            }
            message = Constant.CreateSuccess;
            return(CreateCategory.MapToEditModel());
        }
Esempio n. 2
0
        public bool UpdateCategory(CategoryEditModels model, out string message)
        {
            var CategoryEntity = _CategoryRepository.GetById(model.CategoryId);

            if (CategoryEntity != null)
            {
                var gr = _CategoryRepository.getCategory(model.CategoryId, model.CategoryName);
                if (gr != null)
                {
                    message = Constant.CategoryIsExist;
                    return(false);
                }
                CategoryEntity = model.MapToEditEntity(CategoryEntity);
                _CategoryRepository.Update(CategoryEntity);
                UnitOfwork.SaveChanges();
                message = Constant.UpdateSuccess;
                return(true);
            }
            message = Constant.UpdateFail;
            return(false);
        }