public async Task InsertOrders(int service, List <double> carBody, List <int> id, List <int> sum, double total) { OrderServicesCarWashBll OrderFormation = new OrderServicesCarWashBll(); OrderFormation = new OrderServicesCarWashBll { IdClientsOfCarWash = OrderServices.idClient, StatusOrder = 1, OrderDate = DateTime.Now, TotalCostOfAllServices = _orderServices.OrderPrice(), DiscountPrice = Math.Round(total), typeOfOrder = service }; int orderServicesCar = await CreateOrder(OrderFormation); foreach (var item in OrderServices.OrderList) { _servisesCar = new ServisesCarWashOrderBll { IdClientsOfCarWash = Convert.ToInt32(OrderServices.idClient), IdOrderServicesCarWash = orderServicesCar, IdWashServices = item.Id, Price = PriceServices(carBody, id, sum, item.Id) }; ServisesCarWashOrder servisesCarWash = Mapper.Map <ServisesCarWashOrderBll, ServisesCarWashOrder>(_servisesCar); _unitOfWork.ServisesCarWashOrderUnitOfWork.Insert(servisesCarWash); await _unitOfWork.Save(); } _orderServices.ClearListOrder(); }
// GET: ClientsOfCarWashViews/Details/5 public async Task <ActionResult> NewOrder(int?id, string body, int?Services, int?idOrderServices = null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (idOrderServices != null) { TempData["OrderServices"] = idOrderServices; } if (Services == null) { return(RedirectToRoute(new { controller = "Order", action = "Index" })); } else if (Services != null) { TempData["typeServices"] = Services; } _orderServices.ClearListOrder(); OrderServices.idClient = id; OrderServices.body = body; var CustomerOrders = Mapper.Map <ClientsOfCarWashView>(await _services.GetId(id)); Price = Mapper.Map <IEnumerable <DetailingsView> >(await _detailings.Converter()); Price = Price.Where(x => x.mark == false); var tablePriceResult = Price.Where(x => x.IdTypeService == Services).OrderByDescending(x => x.sorting); var detailingsGrup = await _groupWashServices.GetIdAll(Services); ViewBag.Detailings = tablePriceResult; ViewBag.DetailingsGrup = detailingsGrup; if (CustomerOrders == null) { return(HttpNotFound()); } return(View(CustomerOrders)); }