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 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")); }
public SubCategory Insert(SubCategory subCategory) { _subcategoryRepository.Insert(subCategory); return(subCategory); }