public Order getOrder(int? id) { if(id == 0) { var order = new Order(); order.OrderId = 0; return order; } else { var ord = new Order() { OrderId = 1, Address = "Los", City = "Angeles", FirstName = "Hellloooo", LastName = "Bellooooo", Email = "*****@*****.**", OrderDate = DateTime.Now, Phone = "123456", PostalCode = "123", Total = 1234, UserId = "1", Username = "******" }; return ord; } }
public int CreateOrder(Order order, ShoppingCart cart) { decimal orderTotal = 0; var cartItems = GetCartItems(cart); foreach (var item in cartItems) { var orderDetail = new OrderDetail { ProductId = item.ProductId, OrderId = order.OrderId, ProductPrice = item.Product.Price, Quantity = item.Count }; orderTotal += (item.Count * item.Product.Price); storeDB.OrderDetails.Add(orderDetail); } order.Total = orderTotal; order.OrderDetails = storeDB.OrderDetails.Where(o => o.OrderId == order.OrderId).ToList(); storeDB.SaveChanges(); EmptyCart(cart); return order.OrderId; }
public ActionResult AddressAndPayment(FormCollection values) { var order = new Order(); TryUpdateModel(order); try { if(string.Equals(values["Promotion_Code_Box"], string.Empty) == true) { order.Username = User.Identity.Name; order.UserId = User.Identity.GetUserId(); order.OrderDate = DateTime.Now; db.addOrder(order); var cart = cartBLL.GetCart(this.HttpContext); var tot = cartBLL.getTotalBefore(order, cart); cartBLL.CreateOrder(order, cart); order.Total = tot; db.editOrder(order); order.OrderDetails = order.OrderDetails; db.save(); return RedirectToAction("Complete", new { id = order.OrderId }); } else if (string.Equals(values["Promotion_Code_Box"], PromotionCode, StringComparison.OrdinalIgnoreCase) == false) { ViewBag.Wrong = " Wrong Promotion Code. Please write a valid promotion code, or leave this field empty."; return View(order); } else { order.Username = User.Identity.Name; order.OrderDate = DateTime.Now; db.addOrder(order); db.save(); var cart = cartBLL.GetCart(this.HttpContext); var tot = cartBLL.getTotalBefore(order, cart); cartBLL.CreateOrder(order, cart); order.Total = tot / 2; db.editOrder(order); db.save(); return RedirectToAction("Complete", new { id = order.OrderId }); } } catch { return View(order); } }
public ActionResult Create(Order order) { if (ModelState.IsValid) { db.addOrder(order); return RedirectToAction("Index"); } return View(order); }
public bool editOrder(Order order) { if(order != null) { return true; } else { return false; } }
public int CreateOrder(Order order, ShoppingCart cart) { if (order != null && cart != null) { return 1; } else { return -1; } }
public bool addOrder(Order order) { var db = new ProductContext(); if(order != null) { db.Orders.Add(order); db.SaveChanges(); return true; } return false; }
public bool editOrder(Order order) { if(order != null) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return true; } else { return false; } }
public IEnumerable<Order> getOrderHistory(string id) { if(!id.Equals(String.Empty)) { var oh = new List<Order>(); var ord = new Order() { OrderId = 1, Address = "Los", City = "Angeles", FirstName = "Hellloooo", LastName = "Bellooooo", Email = "*****@*****.**", OrderDate = DateTime.Now, Phone = "123456", PostalCode = "123", Total = 1234, UserId = "1", Username = "******" }; oh.Add(ord); oh.Add(ord); return oh; } else { return null; } }
public bool editOrder(Order order) { return db.editOrder(order); }
public bool addOrder(Order order) { var db = new OrderDAL(); return db.addOrder(order); }
public decimal getTotalBefore(Order order, ShoppingCart cart) { return temp.getTotalBefore(order, cart); }
public int CreateOrder(Order order, ShoppingCart cart) { return temp.CreateOrder(order, cart); }
public decimal getTotalBefore(Order order, ShoppingCart cart) { decimal orderTotal = 0; var cartItems = GetCartItems(cart); foreach (var item in cartItems) { orderTotal += (item.Count * item.Product.Price); } return orderTotal; }
public decimal getTotalBefore(Order order, ShoppingCart cart) { if (order != null && cart != null) { return 1; } else { return -1; } }