public void UpdateCategory(Category category) { eCommerceContext context = new eCommerceContext(); context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public bool AddOrderHistory(OrderHistory orderHistory) { eCommerceContext context = new eCommerceContext(); context.OrderHistories.Add(orderHistory); return(context.SaveChanges() > 0); }
public void SaveProduct(Product Product) { eCommerceContext context = new eCommerceContext(); context.Products.Add(Product); context.SaveChanges(); }
public void UpdateSupplier(Supplier supplier) { eCommerceContext context = new eCommerceContext(); context.Entry(supplier).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public bool SaveOrder(Order order) { eCommerceContext context = new eCommerceContext(); context.Orders.Add(order); return(context.SaveChanges() > 0); }
public void SavePromo(Promo Promo) { eCommerceContext context = new eCommerceContext(); context.Promos.Add(Promo); context.SaveChanges(); }
public void SaveSupplier(Supplier supplier) { eCommerceContext context = new eCommerceContext(); context.Suppliers.Add(supplier); context.SaveChanges(); }
public bool AddComment(Comment comment) { eCommerceContext context = new eCommerceContext(); context.Comments.Add(comment); return(context.SaveChanges() > 0); }
public void UpdateConfiguration(Configuration configuration) { eCommerceContext context = new eCommerceContext(); context.Entry(configuration).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public void SaveCategory(Category category) { eCommerceContext context = new eCommerceContext(); context.Categories.Add(category); context.SaveChanges(); }
public void UpdatePromo(Promo Promo) { eCommerceContext context = new eCommerceContext(); var exitingPromo = context.Promos.Find(Promo.ID); context.Entry(exitingPromo).CurrentValues.SetValues(Promo); context.SaveChanges(); }
public int SavePicture(Picture picture) { eCommerceContext context = new eCommerceContext(); context.Pictures.Add(picture); context.SaveChanges(); return(picture.ID); }
public Payment AddUserPayment(Payment payment) { eCommerceContext context = new eCommerceContext(); var paymentToAdd = context.Payment.Add(payment); context.SaveChanges(); return(paymentToAdd); }
public bool DeleteSupplier(int ID) { using (var context = new eCommerceContext()) { var supplier = context.Suppliers.Find(ID); context.Suppliers.Remove(supplier); return(context.SaveChanges() > 0); } }
public bool DeleteCategory(int ID) { using (var context = new eCommerceContext()) { var category = context.Categories.Find(ID); context.Categories.Remove(category); return(context.SaveChanges() > 0); } }
public bool DeletePromo(int ID) { using (var context = new eCommerceContext()) { var promo = context.Promos.Find(ID); context.Promos.Remove(promo); return(context.SaveChanges() > 0); } }
public void UpdateConfigurationValue(string key, string value) { eCommerceContext context = new eCommerceContext(); var configuration = context.Configurations.Find(key); configuration.Value = value; context.Entry(configuration).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public bool DeleteComment(int ID) { eCommerceContext context = new eCommerceContext(); var comment = context.Comments.Find(ID); if (comment != null) { context.Entry(comment).State = System.Data.Entity.EntityState.Deleted; } return(context.SaveChanges() > 0); }
public IActionResult AddingProduct(Product product) { if (ModelState.IsValid) { _context.products.Add(product); _context.SaveChanges(); return(RedirectToAction("AllProducts")); } else { return(View("AddProduct")); } }
public IActionResult AddingCustomer(Customer customer) { if (ModelState.IsValid) { customer.created_at = DateTime.Now; _context.customers.Add(customer); _context.SaveChanges(); return(RedirectToAction("AllCustomers")); } else { return(View("AddCustomer")); } }
public IActionResult AddingToOrder(int productid, int quantity, int customerid) { TempData["CustomerId"] = TempData["CustomerId"]; List <Cart_Item> CartItems = _context.cart_items.Where(c => c.customer_id == customerid).Where(c => c.product_id == productid).ToList(); if (CartItems.Count() > 0) { Cart_Item CurrentCartItem = CartItems.First(); CurrentCartItem.product_quantity += quantity; _context.SaveChanges(); return(RedirectToAction("AllOrders")); } else { Cart_Item InstallingCartItem = new Cart_Item(); InstallingCartItem.customer_id = customerid; InstallingCartItem.product_id = productid; InstallingCartItem.product_quantity = quantity; _context.cart_items.Add(InstallingCartItem); _context.SaveChanges(); return(RedirectToAction("AllOrders")); } }
public void UpdateProduct(Product Product) { eCommerceContext context = new eCommerceContext(); var exitingProduct = context.Products.Find(Product.ID); context.ProductPictures.RemoveRange(exitingProduct.ProductPictures); context.ProductSpecifications.RemoveRange(exitingProduct.ProductSpecifications); context.ProductCosts.RemoveRange(exitingProduct.ProductCosts); context.Entry(exitingProduct).CurrentValues.SetValues(Product); context.ProductPictures.AddRange(Product.ProductPictures); context.ProductSpecifications.AddRange(Product.ProductSpecifications); context.ProductCosts.AddRange(Product.ProductCosts); context.SaveChanges(); }
public bool SaveChanges() { try { if (_context.SaveChanges() > 0) { return(true); } return(false); } catch (DbEntityValidationException ex) { foreach (var validationMessages in ex.EntityValidationErrors) { foreach (var validationError in validationMessages.ValidationErrors) { errorMessage += Environment.NewLine + string.Format("Property : {0} Error : {1}", validationError.PropertyName, validationError.ErrorMessage); } } throw new Exception(errorMessage, ex); //return false; } }
public static ShoppingCartItem AddItem(AddItemDto item, eCommerceContext _context) { if (!_context.Product.Any(x => x.ProductId == item.ProductId)) { return(null); } if (item.Quantity <= 0) { return(null); } API.Models.ShoppingCart cart = _context.ShoppingCart.FirstOrDefault(x => x.ShoppingCartId == item.ShoppingCartID); if (cart == null) { cart = new API.Models.ShoppingCart() { LastUpdated = DateTime.Now } } ; var cartItem = new ShoppingCartItem() { ProductId = item.ProductId ?? 0, Quantity = item.Quantity ?? 0 }; cart.ShoppingCartItem = new[] { cartItem }; _context.SaveChanges(); return(cartItem); } }
public void SaveChanges() { _context.SaveChanges(); }