public async Task <OrderColorModel> OrderingColor(List <int> idServes, int?idClient)
        {
            OrderColorModel orderColorModel = new OrderColorModel();

            orderColorModel.priceColor = await _priceColor.SelectGroupValue(idServes);

            orderColorModel.clientInfo = await _clientInfo.ClientInfoGetId(idClient);

            return(orderColorModel);
        }
        public async Task <OrderColorModel> OrderingColor(int idClient)
        {
            OrderColorModel orderColor = new OrderColorModel();

            orderColor.nameGroup = await _groupColor.GetTableAll();

            orderColor.priceColor = await _priceColor.GetTableAll();

            orderColor.clientInfo = await _clientInfo.ClientInfoGetId(idClient);

            return(orderColor);
        }
        public async Task <ActionResult> Preview(int?idStatusOrder, int?idPaymentState, string adress, string number)
        {
            var orderColor = new OrderColorModel();

            if (TempData.ContainsKey("order"))
            {
                orderColor = TempData["order"] as OrderColorModel;
                await _orderColor.SaveOrder(orderColor);
            }

            TempData.Keep("order");

            return(RedirectToAction("Index", "Color"));
        }
        public async Task SaveOrder(OrderColorModel orderColor)
        {
            var idOrder = await SaveOrderServices(orderColor.sumOrder.Value);

            ServiceColorBll serviceColor = new ServiceColorBll();

            foreach (var item in orderColor.priceColor)
            {
                serviceColor.clientsOfCarWashId     = orderColor.clientInfo.Id;
                serviceColor.orderServicesCarWashId = idOrder;
                serviceColor.priceColorId           = item.idColor;
                serviceColor.price = item.Price;

                await _colorServices.Insert(serviceColor);
            }
        }
        public async Task <OrderColorModel> OrderCost(OrderColorModel orderColor, bool difficultyWork, bool workSpeed)
        {
            double?sumOrder = orderColor.priceColor.Sum(s => s.Price);

            orderColor.sumColor = sumOrder;

            const double percentageOrder = 0.5;

            if (difficultyWork)
            {
                sumOrder = sumOrder * percentageOrder + sumOrder;
            }

            if (workSpeed)
            {
                sumOrder = sumOrder * percentageOrder + sumOrder;
            }

            orderColor.sumOrder       = sumOrder;
            orderColor.difficultyWork = difficultyWork;
            orderColor.workSpeed      = workSpeed;

            return(orderColor);
        }