//Update Category public bool UpdateCategory(PostCategoryModel category) { var categoryInDb = _categoryRepository.Table.Where(c => c.Id == category.Id).FirstOrDefault(); if (categoryInDb != null) { categoryInDb.Name = category.Name; categoryInDb.Description = category.Description; categoryInDb.IsActive = category.IsActive; categoryInDb.DateUpdated = DateTime.Now; _categoryRepository.Update(categoryInDb); return(true); } return(false); }
//Add Category public bool AddCategory(PostCategoryModel category) { var categoryInDb = new Z_Harag_Category { Name = category.Name, Description = category.Description, IsActive = category.IsActive, DateCreated = DateTime.Now }; if (categoryInDb != null) { _categoryRepository.Insert(categoryInDb); return(true); } return(false); }