Ejemplo n.º 1
0
        public DetailModel(CustomerReport customerReport)
        {
            AddressModels = new List<AddressModel>();

            this.CustomerReport = customerReport;

            this.AggregateRootId = customerReport.AggregateRootId;

            AddressTypes = new SelectList(new List<string>{ Add.AddressType.Home.ToString(),Add.AddressType.Billing.ToString()});

            if (customerReport.Address1G1 != null)
                AddressModels.Add(new AddressModel { Address1 = customerReport.Address1G1, Address2 = customerReport.Address2G1, AddressType = customerReport.AddressTypeG1, PostCode = customerReport.PostCodeG1 });

            if (customerReport.Address1G2 != null)
                AddressModels.Add(new AddressModel { Address1 = customerReport.Address1G2, Address2 = customerReport.Address2G2, AddressType = customerReport.AddressTypeG2, PostCode = customerReport.PostCodeG2 });
        }
Ejemplo 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();
        }