public async Task <ActionResult> Order() { var cart = await _repository.GetCartListAsync(User.Identity.GetUserId()); if (cart == null || cart.Count() == 0) { return(RedirectToAction("List", "ShoppingCart")); } var order = new Orders() { UserId = User.Identity.GetUserId(), Date = DateTime.Now, Status = "OCZEKUJĄCE" }; foreach (var item in cart) { var product = await _repository.GetProductAsync(item.ProductId); order.Name += item.Quantity + " x " + product.Name + ", "; order.Price += item.Price; await _repository.ReduceProductStack(product.Id, item.Quantity); } await _repository.AddOrderAsync(order); await _repository.ClearCartAsync(order.UserId); return(View(order)); }