public ActionResult PlaceOrder(List <CartProduct> cpList) { OrderVM orderVM = new OrderVM(); orderVM.address = new address(); orderVM.customer = new customer(); orderVM.orderItems = new List <orderitem>(); double total = 0; if (cpList != null) { foreach (var cProd in cpList) { orderitem oi = new orderitem(); oi.ProductID = cProd.productID; oi.Price = cProd.price; oi.Quantity = cProd.quantity; orderVM.orderItems.Add(oi); if (cProd.price != 0 && cProd.quantity != 0) { total = ((double)cProd.price * cProd.quantity) + total; } } orderVM.order = new order(); orderVM.order.TotalPrice = total; orderVM.order.GST = 5; orderVM.order.GrandTotalWithTax = total; orderVM.order.DeliveryDate = DateTime.Now.AddDays(30); orderVM.order.Discount = 0; orderVM.order.Advance = 0; } return(View(orderVM)); }
public void obieqtiscashla(orderitem k) { produqtiscashla pc = new produqtiscashla(k.raodenoba); pc.ShowDialog(); var raodenoba = pc.textboqsisraodenoba; if (o.produqtisdamateba.Any(o => o.raodenoba == raodenoba)) { var h = o.removeproduqts(k, raodenoba); dataGridView1.DataSource = null; dataGridView1.DataSource = h; label2.Text = o.TotalCount().ToString(); } else { var darcheniliraodenoba = o.produqtisdamateba.Single(o => o == k); var g = darcheniliraodenoba.raodenoba - raodenoba; o.produqtisdamateba.Single(o => o == k).raodenoba = g; dataGridView1.DataSource = null; dataGridView1.DataSource = o.produqtisdamateba; label2.Text = o.TotalCount().ToString() + '₾'; } }
public bool UpdateOrderItem(orderitem instance) { orderitem cache = dbContext.orderitems.Where(oi => oi.idorderitem == instance.idorderitem).FirstOrDefault(); if (cache != null) { dbContext.SubmitChanges(); return(true); } return(false); }
public bool RemoveOrderItem(int idorderitem) { orderitem instance = dbContext.orderitems.FirstOrDefault <orderitem>(oi => oi.idorderitem == idorderitem); if (instance != null) { dbContext.orderitems.DeleteOnSubmit(instance); dbContext.SubmitChanges(); return(true); } return(false); }
public ActionResult buynow() { List <orderitem> olist = (List <orderitem>)Session["cart"]; var q = from o in olist join p in db.productdetails on o.productcode equals p.productcode join ps in db.productstocks on p.product_stock_id equals ps.productstockid select new JointModels { Orderitem = o, Productdetail = p, PStock = ps }; int totalamount = 0; foreach (var it in q) { totalamount += (int)(it.Orderitem.quantity * it.Productdetail.price); } String email = Session["username"].ToString(); int shopid = db.shops.Single(s => s.email == email).shopid; int orderid = DateTime.Now.Millisecond + shopid; shoporder order = new shoporder(); order.shoporderid = orderid; order.date = DateTime.Now; order.total_amount = totalamount; order.status = "order"; order.remarks = ""; order.shopid = shopid; db.shoporders.Add(order); foreach (var it in q) { orderitem item = new orderitem(); item.productcode = it.Orderitem.productcode; item.quantity = it.Orderitem.quantity; item.total = (int)(it.Orderitem.quantity * it.Productdetail.price); item.shoporderid = orderid; db.orderitems.Add(item); } db.SaveChanges(); Session["cart"] = null; return(RedirectToAction("showorders")); }
private orderitem GetOrderItem(orderitem orderItem, OrderItem orderItemFile) { orderItem.ConditionNote = orderItemFile.ConditionNote; orderItem.GiftWrapPrice = orderItemFile.GiftWrapPrice; orderItem.GiftWrapTax = orderItemFile.GiftWrapTax; orderItem.ItemTax = orderItemFile.ItemTax; orderItem.OrderId = orderItemFile.OrderId; orderItem.OrderItemId = orderItemFile.OrderItemId; orderItem.Price = orderItemFile.Price; orderItem.PromotionDiscount = orderItemFile.PromotionDiscount; orderItem.QtyOrdered = orderItemFile.QtyOrdered; orderItem.QtyShipped = orderItemFile.QtyShipped; orderItem.ShippingDiscount = orderItemFile.ShippingDiscount; orderItem.ShippingPrice = orderItemFile.ShippingPrice; orderItem.ShippingTax = orderItemFile.ShippingTax; orderItem.SKU = orderItemFile.SKU; orderItem.Title = orderItemFile.Title; return(orderItem); }
public int addOrder(List <OrderItemCustom> orderItems, decimal totalPrice, int tableId) { using (restaurantEntities context = new restaurantEntities()) { try { //first we create the order object order newOrder = new order { date = DateTime.Now, time = DateTime.Now.TimeOfDay, total = totalPrice, accepted = 0, Table_id = tableId }; context.order.Add(newOrder); context.SaveChanges(); //creating order items foreach (var item in orderItems) { orderitem newOrderItem = new orderitem { Order_id = newOrder.id, Item_id = item.id, quantity = item.quantity, price = item.price }; context.orderitem.Add(newOrderItem); } context.SaveChanges(); return(newOrder.id); } catch (Exception ex) { return(0); } } }
public void ManageOrders(Order orderFile) { if (string.IsNullOrEmpty(orderFile.OrderId)) { return; } using (var context = new EisInventoryContext()) { // get the information var order = context.orders .FirstOrDefault(x => x.OrderId == orderFile.OrderId); if (order == null) { var eisOrderId = getMaxEisOrderId() + 1; order = new order(); order = GetOrderModel(order, orderFile); order.EisOrderId = eisOrderId; context.orders.Add(order); context.SaveChanges(); var orderItem = new orderitem(); foreach (var item in orderFile.OrderItems) { orderItem = new orderitem(); orderItem = GetOrderItem(orderItem, item); context.orderitems.Add(orderItem); context.SaveChanges(); } } //else //{ // order = GetOrderModel(order, orderFile); // context.SaveChanges(); //} } }
public ActionResult saveshop_order(int qty, int productcode) { if (Session["cart"] == null) { orderitem oitem = new orderitem(); oitem.quantity = qty; oitem.productcode = productcode; List <orderitem> olist = new List <orderitem>(); olist.Add(oitem); Session["cart"] = olist; } else { List <orderitem> olist = (List <orderitem>)Session["cart"]; orderitem oitem = olist.SingleOrDefault(g => g.productcode == productcode); if (oitem == null) { oitem = new orderitem(); oitem.quantity = qty; oitem.productcode = productcode; olist.Add(oitem); } else { oitem.quantity += qty; } Session["cart"] = olist; } return(RedirectToAction("showcart")); }
public OrderListViewModel UpdateMarketplaceOrder(string marketplaceOrderId, MarketplaceOrder order) { // let's get first the order data var existingOrder = _context.orders.FirstOrDefault(x => x.OrderId == marketplaceOrderId); if (existingOrder == null) { return(null); } // update each properties of the existing order one by one existingOrder.Marketplace = order.Marketplace; existingOrder.OrderTotal = order.OrderTotal; existingOrder.NumOfItemsShipped = (int)order.NumOfItemsShipped; existingOrder.NumOfItemsUnshipped = (int)order.NumOfItemsUnshipped; existingOrder.OrderStatus = order.OrderStatus; existingOrder.PurchaseDate = order.PurchaseDate; existingOrder.LastUpdateDate = order.LastUpdateDate; existingOrder.PaymentMethod = order.PaymentMethod; existingOrder.BuyerName = order.BuyerName; existingOrder.BuyerEmail = order.BuyerEmail; existingOrder.ShippingAddressPhone = order.ShippingAddressPhone; existingOrder.ShippingAddressName = order.ShippingAddressName; existingOrder.ShippingAddressLine1 = order.ShippingAddressLine1; existingOrder.ShippingAddressLine2 = order.ShippingAddressLine2; existingOrder.ShippingAddressLine3 = order.ShippingAddressLine3; existingOrder.ShippingCity = order.ShippingCity; existingOrder.ShippingStateOrRegion = order.ShippingStateOrRegion; existingOrder.ShippingPostalCode = order.ShippingPostalCode; existingOrder.ShipServiceLevel = order.ShipServiceLevel; existingOrder.ShipmentServiceCategory = order.ShipmentServiceCategory; existingOrder.EarliestShipDate = order.EarliestShipDate; existingOrder.LatestShipDate = order.LatestShipDate; existingOrder.EarliestDeliveryDate = order.EarliestDeliveryDate; existingOrder.LatestDeliveryDate = order.LatestDeliveryDate; existingOrder.OrderType = order.OrderType; existingOrder.MarketplaceId = order.MarketplaceId; existingOrder.PurchaseOrderNumber = order.PurchaseOrderNumber; existingOrder.SalesChannel = order.SalesChannel; existingOrder.SellerOrderId = order.SellerOrderId; existingOrder.AdjustmentAmount = order.AdjustmentAmount; existingOrder.AmountPaid = order.AmountPaid; existingOrder.PaymentOrRefundAmount = order.PaymentOrRefundAmount; existingOrder.CompanyName = order.CompanyName; // save the changes first _context.SaveChanges(); // then, its order items foreach (var item in order.OrderItems) { // check if has an existing order item var existingOrderItem = _context.orderitems .FirstOrDefault(x => x.OrderId == item.OrderId && x.OrderItemId == item.OrderItemId); if (existingOrderItem == null) { existingOrderItem = new orderitem { OrderId = item.OrderId, OrderItemId = item.OrderItemId }; _context.orderitems.Add(existingOrderItem); } // set it's values existingOrderItem.ItemId = item.MarketplaceItemId; existingOrderItem.SKU = item.SKU; existingOrderItem.Title = item.Title; existingOrderItem.QtyOrdered = item.QtyOrdered; existingOrderItem.QtyShipped = item.QtyShipped; existingOrderItem.Price = item.Price; existingOrderItem.ShippingPrice = item.ShippingPrice; existingOrderItem.GiftWrapPrice = item.GiftWrapPrice; existingOrderItem.ItemTax = item.Tax; existingOrderItem.ShippingTax = item.ShippingTax; existingOrderItem.GiftWrapTax = item.GiftWrapTax; existingOrderItem.ShippingDiscount = item.ShippingDiscount; existingOrderItem.PromotionDiscount = item.PromotionDiscount; existingOrderItem.ConditionNote = item.ConditionNote; } // save the changes _context.SaveChanges(); return(Mapper.Map <OrderListViewModel>(existingOrder)); }