public async Task <IActionResult> FinishOrder(int?IdPayment, int?DeliveryType, TestSummary model) { if (IdPayment == null || DeliveryType == null) { ViewData["Types"] = true; return(await OrderFinish()); } var user = await _userManager.GetUserAsync(User); var payment = _orderService.AddGetPayment(IdPayment.Value, model.OverallPrice); var date = DateTime.Now; var newOrder = _orderService.AddOrder(user.Id, payment.IdPayment, DeliveryType.Value, date); var pom = _orderService.GetUserCart(user.Id); foreach (var item in pom) { _orderService.AddOrderFilm(newOrder.IdOrder, item.Film.IdFilm, item.Amount.Value, item.IdTime, item.IdDate, item.IdCartFilm); _orderService.DeleteCartFilm(item.IdCartFilm); } return(RedirectToAction(nameof(HomeController.Index), "Home")); }