public int Create(Category categoryToCreate) { if (categoryToCreate == null) { throw new Exception("The Category sent in for creation is null."); } base.UpdateIsDeletedToFalse(categoryToCreate); base.UpdateDateAdded(categoryToCreate); db.Categories.Add(categoryToCreate); db.SaveChanges(); int idOfCategory = categoryToCreate.ID; return idOfCategory; }
public void Delete(Category categoryToDelete) { Delete(categoryToDelete.ID); }
public int Update(Category updatedCategory) { Category categoryToUpdate = db.Categories.SingleOrDefault(c => c.ID == updatedCategory.ID && c.IsDeleted == false); if (categoryToUpdate == null) { throw new Exception("No Category exists with the id " + updatedCategory.ID); } base.UpdateDateUpdated(updatedCategory); db.Categories.AddOrUpdate(c => c.ID, updatedCategory); db.SaveChanges(); int idOfCategory = categoryToUpdate.ID; return idOfCategory; }
public Category Get(Category categoryToGet) { return Get(categoryToGet.Name); }
public void Destroy(Category categoryToDestroy) { Destroy(categoryToDestroy.ID); }
private CategoryDisplayViewModel ConvertCategoryToCategoryDisplayViewModel(Category model) { return new CategoryDisplayViewModel { Name = model.Name, IsDeleted = model.IsDeleted, DateAdded = model.DateAdded, DateDeleted = model.DateDeleted, DateUpdated = model.DateUpdated }; }