public int AddProduct(Product product) { using (var context = new EFSportsStoreContext()) { context.Product.Add(product); context.SaveChanges(); }; return product.Id; }
public int AddProduct(Product product) { using (var context = new EFSportsStoreContext()) { context.Product.Add(product); context.SaveChanges(); }; return(product.Id); }
public int AddCategory(Category category) { using (var context = new EFSportsStoreContext()) { context.Category.Add(category); context.SaveChanges(); }; return category.Id; }
public int AddCategory(Category category) { using (var context = new EFSportsStoreContext()) { context.Category.Add(category); context.SaveChanges(); }; return(category.Id); }
public bool DeleteProduct(int id) { var isDeleted = false; using (var context = new EFSportsStoreContext()) { var existingProduct = GetExistingProduct(id, context); if (existingProduct != null) { context.Product.Remove(existingProduct); context.SaveChanges(); isDeleted = true; } } return isDeleted; }
public bool DeleteCategory(int id) { var isDeleted = false; using (var context = new EFSportsStoreContext()) { var existingcategory = GetExistingCategory(id, context); if (existingcategory != null) { context.Category.Remove(existingcategory); context.SaveChanges(); isDeleted = true; } } return isDeleted; }
public bool DeleteProduct(int id) { var isDeleted = false; using (var context = new EFSportsStoreContext()) { var existingProduct = GetExistingProduct(id, context); if (existingProduct != null) { context.Product.Remove(existingProduct); context.SaveChanges(); isDeleted = true; } } return(isDeleted); }
public bool DeleteCategory(int id) { var isDeleted = false; using (var context = new EFSportsStoreContext()) { var existingcategory = GetExistingCategory(id, context); if (existingcategory != null) { context.Category.Remove(existingcategory); context.SaveChanges(); isDeleted = true; } } return(isDeleted); }
public bool EditCategory(Category category) { var isUpdated = false; using (var context = new EFSportsStoreContext()) { var existingcategory = GetExistingCategory(category.Id, context); if (existingcategory != null) { existingcategory.Name = category.Name; context.Entry(existingcategory).State = EntityState.Modified; context.SaveChanges(); isUpdated = true; } } return isUpdated; }
public bool EditCategory(Category category) { var isUpdated = false; using (var context = new EFSportsStoreContext()) { var existingcategory = GetExistingCategory(category.Id, context); if (existingcategory != null) { existingcategory.Name = category.Name; context.Entry(existingcategory).State = EntityState.Modified; context.SaveChanges(); isUpdated = true; } } return(isUpdated); }
public bool EditProduct(Product product) { var isUpdated = false; using (var context = new EFSportsStoreContext()) { var existingProduct = GetExistingProduct(product.Id, context); if (existingProduct != null) { existingProduct.CategoryId = product.CategoryId; existingProduct.Description = product.Description; existingProduct.Name = product.Name; existingProduct.Price = product.Price; context.Entry(existingProduct).State = EntityState.Modified; context.SaveChanges(); isUpdated = true; } } return isUpdated; }
public bool EditProduct(Product product) { var isUpdated = false; using (var context = new EFSportsStoreContext()) { var existingProduct = GetExistingProduct(product.Id, context); if (existingProduct != null) { existingProduct.CategoryId = product.CategoryId; existingProduct.Description = product.Description; existingProduct.Name = product.Name; existingProduct.Price = product.Price; context.Entry(existingProduct).State = EntityState.Modified; context.SaveChanges(); isUpdated = true; } } return(isUpdated); }