Example #1
0
        public IActionResult Overview(DeliveryViewModel delivery)
        {
            if (_sessionContainer.BasketCount(HttpContext, "basket") != 0)
            {
                var model = OverviewViewModelMapper.DeliveryViewModelToOverviewViewModel(delivery);
                model.Order.Business = _orderService.GetBusinessById(Convert.ToInt32(delivery.ParcelPickup));
                model.Order.Products = _sessionContainer.GetBasket(HttpContext, "basket");

                model.Subtotal         = model.Order.Products.Select(x => x.Price * x.Amount).Sum();
                model.VATFromPrice     = (model.Subtotal / 100) * 25;
                model.Order.TotalPrice = model.Subtotal + model.VATFromPrice;

                _sessionContainer.AddOrderToSession(HttpContext, "order", model.Order);

                return(View(model));
            }
            else
            {
                OverviewViewModel model = new OverviewViewModel();
                model.Order = new OrderDTO()
                {
                    Person = new PersonDTO()
                    {
                        Address = new AddressDTO()
                    },
                    Business = new BusinessDTO()
                    {
                        Address = new AddressDTO()
                    }
                };
                model.Order.Products = new List <ProductDTO>();
                return(View(model));
            }
        }