public string UpdatePurchasedProduct(int id, PurchasedProduct purchasedProduct) { try { YWC_StorageEntities db = new YWC_StorageEntities(); //Fetch an object from db PurchasedProduct p = db.PurchasedProducts.Find(id); //Replace the data in db p.Name = purchasedProduct.Name; p.Price = purchasedProduct.Price; p.TypeId = purchasedProduct.TypeId; p.Description = purchasedProduct.Description; p.Image = purchasedProduct.Image; p.Stock = purchasedProduct.Stock; p.DatePurchased = purchasedProduct.DatePurchased; p.ClientID = purchasedProduct.ClientID; p.Amount = purchasedProduct.Amount; db.SaveChanges(); return(purchasedProduct.Name + " was successfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateOrder(int id, OrderDetail order) { try { YWC_StorageEntities db = new YWC_StorageEntities(); //Fetch an object from db OrderDetail o = db.OrderDetails.Find(id); //Replace the data in db o.ClientID = order.ClientID; o.DatePurchased = order.DatePurchased; o.Status = order.Status; o.CartID = order.CartID; o.Total = order.Total; o.ClientEmail = order.ClientEmail; db.SaveChanges(); return(order.DatePurchased + " was successfully updated"); } catch (Exception e) { return("Error:" + e); } }
public string InsertOrder(OrderDetail order) { try { YWC_StorageEntities db = new YWC_StorageEntities(); db.OrderDetails.Add(order); db.SaveChanges(); return(order.DatePurchased + " was successfully inserted"); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } }
public string UpdateCart(int id, Cart cart) { try { YWC_StorageEntities db = new YWC_StorageEntities(); //Fetch an object from db Cart p = db.Carts.Find(id); //Replace the data in db p.DatePurchased = cart.DatePurchased; p.ClientID = cart.ClientID; p.Amount = cart.Amount; p.IsInCart = cart.IsInCart; p.ProductID = cart.ProductID; db.SaveChanges(); return(cart.DatePurchased + " was successfully updated"); } catch (Exception e) { return("Error:" + e); } }
public void UpdateInfo(PageContent content) { YWC_StorageEntities db = new YWC_StorageEntities(); PageContent page = db.PageContents.Find(0); page.Home_MainTitle = content.Home_MainTitle; page.Home_Title2 = content.Home_Title2; page.Home_Desc2 = content.Home_Desc2; page.Home_Title3 = content.Home_Title3; page.Home_Desc3 = content.Home_Desc3; page.Home_Title4 = content.Home_Title4; page.Home_Desc4 = content.Home_Desc4; page.Store_MainTitle = content.Store_MainTitle; page.Store_Desc1 = content.Store_Desc1; page.Store_Desc2 = content.Store_Desc2; page.Donation_MainTitle = content.Donation_MainTitle; page.Donation_Desc1 = content.Donation_Desc1; page.Contact_MainTitle = content.Contact_MainTitle; page.Contact_Desc1 = content.Contact_Desc1; page.Contact_Email = content.Contact_Email; page.Contact_Desc2 = content.Contact_Desc2; page.Contact_Tel = content.Contact_Tel; page.Gallery_MainTitle = content.Gallery_MainTitle; page.Gallery_Desc1 = content.Gallery_Desc1; db.SaveChanges(); }
public void InsertUserInformation(UserInformation info) { YWC_StorageEntities db = new YWC_StorageEntities(); db.UserInformations.Add(info); db.SaveChanges(); }
public void addNewTaxShipping() { YWC_StorageEntities db = new YWC_StorageEntities(); TaxShipping taxShip = new TaxShipping(); db.TaxShippings.Add(taxShip); db.SaveChanges(); }
public void deleteTaxShipping() { YWC_StorageEntities db = new YWC_StorageEntities(); TaxShipping taxShip = new TaxShipping(); db.TaxShippings.Remove(taxShip); db.SaveChanges(); }
public void UpdateQuantity(int id, int quantity) { YWC_StorageEntities db = new YWC_StorageEntities(); Cart cart = db.Carts.Find(id); cart.Amount = quantity; db.SaveChanges(); }
public void addNewPageConent() { YWC_StorageEntities db = new YWC_StorageEntities(); PageContent page = new PageContent(); db.PageContents.Add(page); db.SaveChanges(); }
public void UpdateInfo(TaxShipping ts) { YWC_StorageEntities db = new YWC_StorageEntities(); TaxShipping taxShip = db.TaxShippings.Find(0); taxShip.Tax = ts.Tax; taxShip.Shipping = ts.Shipping; db.SaveChanges(); }
public void MarkOrderAsSent(OrderDetail order) { YWC_StorageEntities db = new YWC_StorageEntities(); if (order != null) { OrderDetail oldOrder = db.OrderDetails.Find(order.Id); oldOrder.Status = "SENT"; } db.SaveChanges(); }
public void UpdateStock(int id, int x) { try { using (YWC_StorageEntities db = new YWC_StorageEntities()) { PurchasedProduct purchasedProduct = db.PurchasedProducts.Find(id); purchasedProduct.Stock = x; db.SaveChanges(); } } catch (Exception) { } }
public string InsertCart(Cart cart) { try { YWC_StorageEntities db = new YWC_StorageEntities(); db.Carts.Add(cart); db.SaveChanges(); return(cart.DatePurchased + " was successfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public string InsertPurchasedProduct(PurchasedProduct purchasedProduct) { try { YWC_StorageEntities db = new YWC_StorageEntities(); db.PurchasedProducts.Add(purchasedProduct); db.SaveChanges(); return(purchasedProduct.Name + " was successfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public string InsertProductType(ProductType productType) { try { YWC_StorageEntities db = new YWC_StorageEntities(); db.ProductTypes.Add(productType); db.SaveChanges(); return(productType.Name + " was successfully inserted"); } catch (Exception e) { return("Error:" + e); } }
public void MarkOrdersAsPaid(List <Cart> carts) { YWC_StorageEntities db = new YWC_StorageEntities(); if (carts != null) { foreach (Cart cart in carts) { Cart oldcart = db.Carts.Find(cart.ID); oldcart.DatePurchased = DateTime.Now; oldcart.IsInCart = false; } db.SaveChanges(); } }
public string DeletePurchasedProduct(int id) { try { YWC_StorageEntities db = new YWC_StorageEntities(); PurchasedProduct purchasedProduct = db.PurchasedProducts.Find(id); db.PurchasedProducts.Attach(purchasedProduct); db.PurchasedProducts.Remove(purchasedProduct); db.SaveChanges(); return(purchasedProduct.Name + " was successfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteCart(int id) { try { YWC_StorageEntities db = new YWC_StorageEntities(); Cart cart = db.Carts.Find(id); db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return(cart.DatePurchased + " was successfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteProductType(int id) { try { YWC_StorageEntities db = new YWC_StorageEntities(); ProductType productType = db.ProductTypes.Find(id); db.ProductTypes.Attach(productType); db.ProductTypes.Remove(productType); db.SaveChanges(); return(productType.Name + " was successfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string DeleteOrder(int id) { try { YWC_StorageEntities db = new YWC_StorageEntities(); OrderDetail order = db.OrderDetails.Find(id); db.OrderDetails.Attach(order); db.OrderDetails.Remove(order); db.SaveChanges(); return(order.DatePurchased + " was successfully deleted"); } catch (Exception e) { return("Error:" + e); } }
public string UpdateProductType(int id, ProductType productType) { try { YWC_StorageEntities db = new YWC_StorageEntities(); //Fetch an object from db ProductType p = db.ProductTypes.Find(id); //Replace the data in db p.Name = productType.Name; db.SaveChanges(); return(productType.Name + " was successfully updated"); } catch (Exception e) { return("Error:" + e); } }