public string InsertProductType(ProductType productType) { try { BakeryDBEntities db = new BakeryDBEntities(); db.ProductTypes.Add(productType); db.SaveChanges(); return productType.TName + " was successfully inserted."; } catch (Exception e) { return "Error: " + e.Message; } }
public string InsertCart(Cart cart) { try { BakeryDBEntities db = new BakeryDBEntities(); db.Carts.Add(cart); db.SaveChanges(); return cart.DatePurchased + " was successfully inserted."; } catch (Exception e) { return "Error: " + e.Message; } }
public string UpdateProductType(int id, ProductType productType) { try { BakeryDBEntities db = new BakeryDBEntities(); ProductType p = db.ProductTypes.Find(id); // fetching the object from the db. p.TName = productType.TName; db.SaveChanges(); return productType.TName + " was successfully updated."; } catch (Exception e) { return "Error: " + e.Message; } }
public string DeleteCart(int id) { try { BakeryDBEntities db = new BakeryDBEntities(); Cart cart = db.Carts.Find(id); // fetching the object from the db. db.Carts.Attach(cart); db.Carts.Remove(cart); db.SaveChanges(); return cart.DatePurchased + " was successfully deleted."; } catch (Exception e) { return "Error: " + e.Message; } }
public string DeleteProductType(int id) { try { BakeryDBEntities db = new BakeryDBEntities(); ProductType productType = db.ProductTypes.Find(id); // fetching the object from the db. db.ProductTypes.Attach(productType); db.ProductTypes.Remove(productType); db.SaveChanges(); return productType.TName + " was successfully deleted."; } catch (Exception e) { return "Error: " + e.Message; } }
public string UpdateCart(int id, Cart cart) { try { BakeryDBEntities db = new BakeryDBEntities(); Cart p = db.Carts.Find(id); // fetching the object from the db. p.ClientId = cart.ClientId; p.PId = cart.PId; p.Amount = cart.Amount; p.DatePurchased = cart.DatePurchased; p.IsInCart = cart.IsInCart; db.SaveChanges(); return cart.DatePurchased + " was successfully updated."; } catch (Exception e) { return "Error: " + e.Message; } }
public void InsertUserInformation(UserInfo info) { BakeryDBEntities db = new BakeryDBEntities(); db.UserInfoes.Add(info); db.SaveChanges(); }
public string UpdateProduct(int id, Product product) { try { BakeryDBEntities db = new BakeryDBEntities(); Product p = db.Products.Find(id); // fetching the object from the db. p.PName = product.PName; p.TypeId = product.TypeId; p.Price = product.TypeId; p.Info = product.Info; p.Image = product.Image; db.SaveChanges(); return product.PName + " was successfully updated."; } catch (Exception e) { return "Error: " + e.Message; } }