Exemple #1
0
 public ActionResult Buy(Product product)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (OrdersList.Find(x => x.UserName == User.Identity.Name) == null)
         {
             OrdersList.Add(new OrderListModel()
             {
                 UserName        = User.Identity.Name,
                 OrderedProducts = new List <Product>()
             });
         }
         _catalogService.BuyProduct(product);
         OrderListModel order = OrdersList.Where(x => x.UserName == User.Identity.Name).FirstOrDefault();
         order.OrderedProducts.Add(product);
         return(RedirectToAction("CatalogView", "Catalog"));
     }
     return(RedirectToAction("Login", "Authentication"));
 }