예제 #1
0
        //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);
        }
예제 #2
0
        //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);
        }