Exemplo n.º 1
0
        public ActionResult PlaceOrder()
        {
            using (var s = sf.OpenSession())
            {
                var placeOrderModel = new PlaceOrderModel(s);

                TempData["PlaceOrder"] = placeOrderModel;

                return View(placeOrderModel);
            }
        }
Exemplo n.º 2
0
        private ActionResult AddOrderInMemory(Guid customer, Guid product, int quantity, ref CustomerReport customerReport, ref ProductStockReport productStockReport, ref PlaceOrderModel placeOrderModel, ISession s)
        {
            var _customerReports = s.Query<CustomerReport>().Where(c => c.AggregateRootId == customer);

            var _productReports = s.Query<ProductStockReport>().Where(c => c.AggregateRootId == product);

            if (_customerReports.Count() == 1)
                customerReport = _customerReports.FirstOrDefault();

            if (_productReports.Count() == 1)
                productStockReport = _productReports.FirstOrDefault();

            if (customerReport != null && productStockReport != null)
            {
                var orderItemModel = new OrderItemModel { CustomerName = customerReport.Name, CustomerId = customer, ProductId = product, ProductName = productStockReport.Name + " " + productStockReport.Code, Quantity = quantity };

                if (TempData["PlaceOrder"] != null)
                {
                    placeOrderModel = (PlaceOrderModel)TempData["PlaceOrder"];

                    placeOrderModel.OrderItemModels.Add(orderItemModel);

                    TempData["PlaceOrder"] = placeOrderModel;

                    return View(placeOrderModel);
                }
                else
                {
                    placeOrderModel = new PlaceOrderModel(s);

                    placeOrderModel.OrderItemModels.Add(orderItemModel);

                    TempData["PlaceOrder"] = placeOrderModel;

                    return View(placeOrderModel);
                }

            }
            return View();
        }