Example #1
0
 public void OnGet()
 {
     OfferCreateInput = (OfferCreateInputModel)_sessionHelper.GetItem("CreateOfferInput");
     Name             = OfferCreateInput.Name;
     TotalPrice       = OfferCreateInput.TotalPrice;
     ExpiryDate       = OfferCreateInput.ExpiryDate;
     ImageUrl         = OfferCreateInput.ImageUrl;
     Products         = ((IEnumerable <ProductViewModel>)_sessionHelper.GetItem("AllProducts"))
                        .Select(product =>
                                new SelectListItem
     {
         Value = product.Id.ToString(),
         Text  = product.Name
     })
                        .ToList();
 }
Example #2
0
        public IActionResult OnPost()
        {
            IEnumerable <ProductViewModel> allProducts = (IEnumerable <ProductViewModel>)_sessionHelper.GetItem("AllProducts");
            var totalPrice = allProducts
                             .Where(vm => SelectedProductsIds.Contains(vm.Id))
                             .Sum(p => p.Price);
            var createOfferInput = new OfferCreateInputModel
            {
                Name       = Name,
                ProductIds = SelectedProductsIds.ToArray(),
                TotalPrice = totalPrice,
                ImageUrl   = ImageUrl,
                ExpiryDate = ExpiryDate
            };

            _sessionHelper.AddRenewItem("CreateOfferInput", createOfferInput);
            return(RedirectToPage("./Preview"));
        }