public Category EditCategory(Category category) { // Get original person object from database, no need to assig it to a variable GetCategory(category.CategoryId); _entities.Categories.ApplyCurrentValues(category); _entities.SaveChanges(); return category; }
public bool DeleteCategory(Category category) { try { _categoryRepository.DeleteCategory(category); } catch { return false; } return true; }
public bool EditCategory(Category category) { // Validation logic if (!ValidateCategory(category)) return false; // Database logic try { _categoryRepository.EditCategory(category); } catch { return false; } return true; }
public bool ValidateCategory(Category category) { if (category.CategoryName.Trim().Length == 0) _validationDictionary.AddError("CategoryName", "Category name is required."); return _validationDictionary.IsValid; }
public void DeleteCategory(Category category) { var originalPerson = GetCategory(category.CategoryId); _entities.Categories.DeleteObject(category); _entities.SaveChanges(); }
public Category CreateCategory(Category category) { _entities.AddToCategories(category); _entities.SaveChanges(); return category; }
/// <summary> /// Create a new Category object. /// </summary> /// <param name="categoryId">Initial value of the CategoryId property.</param> public static Category CreateCategory(global::System.Int32 categoryId) { Category category = new Category(); category.CategoryId = categoryId; return category; }
/// <summary> /// Deprecated Method for adding a new object to the Categories EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCategories(Category category) { base.AddObject("Categories", category); }