Пример #1
0
        public async Task <string> AddUpdateSubCategory(SubCategoryDomainModel subCategory)
        {
            string status = "";

            if (subCategory.subCat_id > 0)
            {
                tblSubCategory subCategoryToUpdate = await subCategoryRepository.SingleOrDefault(s => s.subCat_id == subCategory.subCat_id);

                if (subCategoryToUpdate != null)
                {
                    subCategoryToUpdate.subCat_id = subCategory.subCat_id;
                    subCategoryToUpdate.name      = subCategory.name;
                    subCategoryToUpdate.cat_id    = subCategory.cat_id;

                    await subCategoryRepository.Update(subCategoryToUpdate);

                    status = "updated";
                }
            }
            else
            {
                tblSubCategory subCategoryToAdd = new tblSubCategory();
                subCategoryToAdd.subCat_id = subCategory.subCat_id;
                subCategoryToAdd.name      = subCategory.name;
                subCategoryToAdd.cat_id    = subCategory.cat_id;

                await subCategoryRepository.Insert(subCategoryToAdd);

                status = "added";
            }
            return(status);
        }
        public bool Update(SubCategory obj)
        {
            int rowAffected = _Repository.Update(obj);

            bool isUpdated = rowAffected > 0;

            return(isUpdated);
        }
Пример #3
0
        public bool Update(SubCategory subCategory)
        {
            bool isUpdated = repository.Update(subCategory);

            return(isUpdated);

            ;
        }
Пример #4
0
        public void Update(SubCategoryViewModel model)
        {
            var subCategory = new SubCategory()
            {
                Name = model.Name,
                Id   = model.Id,
            };

            _subCategoryRepository.Update(subCategory);
        }
Пример #5
0
        public IActionResult AddOrUpdate(UISubCategoryListCategory model)
        {
            bool b;

            if (model.SubCategory.Id > 0)
            {
                b = repository.Update(model.SubCategory, model.SubCategory.Id);
            }
            else
            {
                b = repository.Insert(model.SubCategory) > 0;
            }
            if (b)
            {
                return(RedirectToAction("AllSubCategory"));
            }
            return(View("AddOrUpdate"));
        }
Пример #6
0
        public bool ChangeSubCategory(int id, int categoryId, bool value)
        {
            var subCategory = new SubCategoryRepository();
            var s           = subCategory.GetByColumName("Id", id).FirstOrDefault();

            if (s == null)
            {
                return(false);
            }
            if (value)
            {
                s.CategoryId = categoryId;
            }
            else
            {
                s.CategoryId = 0;
            }
            return(subCategory.Update(s, id));
        }
Пример #7
0
 public bool Update(SubCategory entity)
 {
     return(_subCategoryRepository.Update(entity));
 }
Пример #8
0
 public SubCategory Update(SubCategory subCategory)
 {
     _subcategoryRepository.Update(subCategory);
     return(subCategory);
 }