public JsonResult CreateOrder(SentOrder sentOrder) { if (Session["ListOfOrders"] == null) { Session["ListOfOrders"] = new List <Order>(); } double pr = 0; foreach (var x in sentOrder.SentOrderItems) { pr += MealsList.theList.Find(z => z.MealName.Equals(x.SentMealName)).MealUnitPrice *x.SentQuantity; } List <OrderItem> finalItems = new List <OrderItem>(); foreach (var y in sentOrder.SentOrderItems) { if (finalItems.Any(k => k.Meal.MealName.Equals(y.SentMealName))) { finalItems.Find(d => d.Meal.MealName.Equals(y.SentMealName)).Quantity += y.SentQuantity; finalItems.Find(d => d.Meal.MealName.Equals(y.SentMealName)).ListPositionPrice += MealsList.theList.Find(l => l.MealName.Equals(y.SentMealName)).MealUnitPrice *y.SentQuantity; } else { finalItems.Add(new OrderItem(MealsList.theList.Find(x => x.MealName.Equals(y.SentMealName)), y.SentQuantity, (MealsList.theList.Find(z => z.MealName.Equals(y.SentMealName)).MealUnitPrice) * y.SentQuantity)); } } Order newRecievedOrder = new Order(finalItems, pr, sentOrder.SentTableNumber, Order.OrderStatus.PendingPayment); var getSessionList = (List <Order>)Session["ListOfOrders"]; getSessionList.Add(newRecievedOrder); Session["ListOfOrders"] = getSessionList; return(Json("")); }
public void Load_history_orders() { session.DeleteEach <SentOrder>(); var offer = session.Query <Offer>().First(o => o.CatalogId == catalog.Id); var order = new Order(offer.Price, address); order.TryOrder(offer, 1); var sentOrder = new SentOrder(order); session.Save(sentOrder); model.CurrentOffer.Value = model.Offers.Value.First(o => o.Id == offer.Id); scheduler.AdvanceToMs(4000); Assert.AreEqual(1, model.HistoryOrders.Value.Count, model.HistoryOrders.Value.Implode(l => l.Id)); Assert.AreEqual(1, model.HistoryOrders.Value[0].Count); Assert.AreEqual(offer.Cost, model.CurrentOffer.Value.PrevOrderAvgCost); Assert.AreEqual(1, model.CurrentOffer.Value.PrevOrderAvgCount); model.CurrentOffer.Value = null; Assert.IsNull(model.HistoryOrders.Value); model.CurrentOffer.Value = model.Offers.Value.First(); Assert.AreEqual(1, model.HistoryOrders.Value.Count); }
public void Restore_order_items_NotEnougth_Error() { session.DeleteEach <Order>(); var offer = session.Query <Offer>().First(o => !session.Query <Offer>().Any(x => x.Price == o.Price && x.ProductId == o.ProductId && x.Id.OfferId != o.Id.OfferId && x.Quantity.Length > 2)); uint rest = 1; var order = new Order(address, offer, (uint)offer.SortQuantity - rest); session.Save(order); var checkResult = $"{order.Price.Name} : {offer.ProductSynonym} - {offer.ProducerSynonym}" + $" ; Уменьшено заказное количество {rest} вместо {order.Lines[0].Count}\r\n"; var sent = new SentOrder(order); session.Save(sent); session.Flush(); var cmd = InitCmd(new UnfreezeCommand <SentOrder>(sent.Id)); cmd.Execute(); Assert.AreEqual((string)cmd.Result, checkResult); }
private BaseDocument BuildPrintOrderDocument(SentOrder order) { var id = order.Id; var result = Env.Query(s => s.Query <SentOrder>() .Where(o => o.Id == id) .Fetch(o => o.Price) .Fetch(o => o.Address) .Fetch(o => o.Lines) .ToList() .First()).Result; return(new OrderDocument(result)); }
public static void SentOrderWithoutOffer(ISession session, bool verbose = false) { var address = session.Query <Address>().First(); var offer = session.Query <Offer>().First(); var order = new Order(address, offer); var sent = new SentOrder(order); var line = sent.Lines[0]; var catalog = session.Query <Catalog>().First(c => !c.HaveOffers); line.CatalogId = catalog.Id; session.Save(sent); if (verbose) { Console.WriteLine("Создан отправленный заказ для товара {0}", catalog.FullName); } }
public static void OldOrder(ISession session) { var offer = session.Query <Offer>().First(x => !x.Junk && x.RequestRatio == null); var address = session.Query <Address>().First(); var order = new Order(address, offer) { CreatedOn = DateTime.Now.AddDays(-100) }; var sent = new SentOrder(order) { SentOn = DateTime.Now.AddDays(-100) }; session.Save(sent); }
public void Restore_order_items_NoOffers_Error() { session.DeleteEach <Order>(); var offer = session.Query <Offer>().First(o => !session.Query <Offer>().Any(x => x.Price == o.Price && x.ProductId == o.ProductId && x.Id.OfferId != o.Id.OfferId && x.Quantity.Length > 2)); var order = new Order(address, offer, (uint)offer.SortQuantity); session.Save(order); var checkResult = $"{order.Price.Name} : {offer.ProductSynonym} - {offer.ProducerSynonym} ; Предложений не найдено\r\n"; var sent = new SentOrder(order); session.Save(sent); session.Flush(); var cmd = InitCmd(new UnfreezeCommand <SentOrder>(sent.Id)); cmd.Execute(); Assert.AreEqual((string)cmd.Result, checkResult); }