public static void Create(string paymentTypeName) { PaymentType pay = PaymentTypeFactory.CreatePayment(paymentTypeName); db.PaymentTypes.Add(pay); db.SaveChanges(); }
public bool checkout(int userID, int paymentID) { HeaderTransaction header = new HeaderTransaction(); header.UserID = userID; header.PaymentTypesID = paymentID; header.Date = DateTime.Now; var head = db.HeaderTransactions.Add(header); if (head == null) { return(false); } db.SaveChanges(); var carts = cartRepository.GetCartByUser(userID); foreach (Cart item in carts) { DetailTransaction detail = new DetailTransaction(); detail.TransactionID = head.TransactionID; detail.ProductID = item.ProductID.Value; detail.Quantity = item.Quantity.Value; db.DetailTransactions.Add(detail); decreaseStock(item.ProductID.Value, item.Quantity.Value); cartRepository.deleteCart(item.ID); db.SaveChanges(); } return(true); }
public static void Create(int productTypeId, String name, int stock, int price) { Product prk = ProductFactory.CreateProduct(productTypeId, name, stock, price); db.Products.Add(prk); db.SaveChanges(); }
public static void Create(String productTypeName, String description) { ProductType prk = ProductTypeFactory.CreateProduct(productTypeName, description); db.ProductTypes.Add(prk); db.SaveChanges(); }
public static User InsertUser(int roleid, string name, string email, string password, string gender, string status) { User u = UserFactory.InsertUser(roleid, name, email, password, gender, status); db.Users.Add(u); db.SaveChanges(); return(u); }
public static Product InsertProduct(int producttypeid, string name, int stock, int price) { Product p = ProductFactory.InsertProduct(producttypeid, name, stock, price); db.Products.Add(p); db.SaveChanges(); return(p); }
public static ProductType InsertProductType(string name, string desc) { ProductType pt = ProductTypeFactory.GetProductType(name, desc); db.ProductTypes.Add(pt); db.SaveChanges(); return(pt); }
public static HeaderTransaction InsertHeaderTransaction(int userId, int paymentTypeId, DateTime date) { HeaderTransaction ht = TransactionFactory.GetHeaderTransaction(userId, paymentTypeId, date); db.HeaderTransactions.Add(ht); db.SaveChanges(); return(ht); }
public static PaymentType InsertPaymentType(string type) { PaymentType pt = PaymentFactory.GetPaymentType(type); db.PaymentTypes.Add(pt); db.SaveChanges(); return(pt); }
public static User doInsertUser(string email, string name, string pwd, string gender) { User users = UserFactory.createUser(email, name, pwd, gender); db.Users.Add(users); db.SaveChanges(); return(users); }
public static Product InsertProduct(int productType, string name, int price, int stock) { Product p = ProductFactory.GetProduct(productType, name, price, stock); db.Products.Add(p); db.SaveChanges(); return(p); }
public static Cart InsertCart(int userId, int productId, int qty) { Cart c = CartFactory.GetCart(userId, productId, qty); db.Carts.Add(c); db.SaveChanges(); return(c); }
public static void AddToCart(Cart carts) { bool check = db.Carts.Any(x => x.UserID == carts.UserID && x.ProductID == carts.ProductID); if(check == true) { Cart existingCart = db.Carts.Where(x => x.UserID == carts.UserID && x.ProductID == carts.ProductID).FirstOrDefault(); existingCart.Quantity += carts.Quantity; db.SaveChanges(); } else { db.Carts.Add(carts); db.SaveChanges(); } }
public static void doInsertDetailTransaction(int transactionId, int productId, int qty) { DetailTransaction dt = DetailTransactionFactory.createDetailTransaction(transactionId, productId, qty); db.DetailTransactions.Add(dt); db.SaveChanges(); }
public static int doInsertTransaction(int userId, int paymentTypeId) { HeaderTransaction ht = HeaderTransactionFactory.CreateHeaderTransaction(userId, paymentTypeId); db.HeaderTransactions.Add(ht); db.SaveChanges(); return(ht.ID); }
public static User RegisterUser(string email, int roleId, string name, string password, string gender, string status) { User u = UserFactory.RegisterUser(email, roleId, name, password, gender, status); db.Users.Add(u); db.SaveChanges(); return(u); }
public static void doInsertProductToCart(int productId, int userId, int qty) { Cart carts = CartFactory.createCart(productId, userId, qty); db.Carts.Add(carts); db.SaveChanges(); }
public void insertProduct(ProductType productType) { db.ProductTypes.Add(productType); db.SaveChanges(); }
public void insertPayment(PaymentType paymentTypes) { db.PaymentTypes.Add(paymentTypes); db.SaveChanges(); }
public void InsertUser(User newUser) { db.Users.Add(newUser); db.SaveChanges(); }
public static void InsertUser(string Name, string Email, string Password, string Gender) { db.MsUsers.Add(UserFactory.InitUser(2, Name, Email, Password, Gender, "A")); db.SaveChanges(); }
public void InsertPaymentType(PaymentType paymentType) { db.PaymentTypes.Add(paymentType); db.SaveChanges(); }
public void insertProduct(Product product) { db.Products.Add(product); db.SaveChanges(); }
public void insertCart(Cart cart) { db.Carts.Add(cart); db.SaveChanges(); }
public void insertUser(User user) { db.Users.Add(user); db.SaveChanges(); }
public static void DeleteProduct(int ID) { db.MsProducts.Remove(GetOneProduct(ID).ElementAt(0)); db.SaveChanges(); }
public void InsertDTransaction(DetailTransaction newDT) { db.DetailTransactions.Add(newDT); db.SaveChanges(); }
public void InsertHTransaction(HeaderTransaction newHT) { db.HeaderTransactions.Add(newHT); db.SaveChanges(); }