public async Task <ActionResult> OrderPreview()
        {
            if (OrderServices.OrderList.Count() > 0)
            {
                double orederSum = 0;

                if (TempData.ContainsKey("OrderServices"))

                {
                    var orderServisesResult = Mapper.Map <IEnumerable <ServisesCarWashOrderView> >(await _servisesCarWash.GetAllId(int.Parse(TempData["OrderServices"].ToString())));
                    orederSum = orderServisesResult.Sum(x => x.Price).Value;

                    ViewBag.OrderServices = orderServisesResult;
                    ViewBag.idOrder       = int.Parse(TempData["OrderServices"].ToString());
                }

                TempData.Keep("typeServices");

                var CustomerOrders = Mapper.Map <ClientsOfCarWashView>(await _services.GetId(OrderServices.idClient));

                var sum       = Math.Ceiling(_orderServices.OrderPrice().Value);
                var sumResult = sum + orederSum;
                var brigade   = Mapper.Map <IEnumerable <BrigadeForTodayView> >(await _brigade.GetDateTimeNow());

                ViewBag.PriceList = OrderServices.OrderList;
                ViewBag.SumOrder  = sumResult;
                ViewBag.Brigade   = brigade.Where(x => x.StatusId == 3);

                if (CustomerOrders.discont > 0)
                {
                    ViewBag.Total = _orderServices.Discont(CustomerOrders.discont, sumResult);
                }
                else
                {
                    ViewBag.Total = sumResult;
                }

                return(View(CustomerOrders));
            }

            return(RedirectToAction("Checkout"));
        }
예제 #2
0
        public async Task RecountOrder(int idOrder, int?ClientDiscont = null)
        {
            OrderServicesCarWashBll WhereIdOrder = await GetId(idOrder);

            OrderServicesCarWash EditOrder = Mapper.Map <OrderServicesCarWashBll, OrderServicesCarWash>(WhereIdOrder);

            var getResult = await _unitOfWork.ServisesCarWashOrderUnitOfWork.GetWhere(x => x.IdOrderServicesCarWash == idOrder);

            EditOrder.TotalCostOfAllServices = getResult.Sum(x => x.Price);

            if (ClientDiscont != null)
            {
                EditOrder.DiscountPrice = _orderServices.Discont(ClientDiscont, EditOrder.TotalCostOfAllServices);
            }
            else
            {
                EditOrder.DiscountPrice = EditOrder.TotalCostOfAllServices;
            }

            _unitOfWork.OrderServicesCarWashUnitOfWork.Update(EditOrder);
            await _unitOfWork.Save();
        }
예제 #3
0
        // db Table [OrderServicesCarWash]
        // Закрыть заказ
        public async Task CloseOrder(int idPaymentState, OrderServicesCarWashBll order, int idStatusOrder)
        {
            order.PaymentState = idPaymentState;

            if (idStatusOrder != 4)
            {
                order.ClosingData = DateTime.Now;
            }

            order.StatusOrder = idStatusOrder;

            if (order.ClientsOfCarWash.discont > 0)
            {
                double x = Convert.ToDouble(_orderServices.Discont(order.ClientsOfCarWash.discont, order.TotalCostOfAllServices));
                order.DiscountPrice = Math.Ceiling(x);
            }
            else
            {
                order.DiscountPrice = order.TotalCostOfAllServices;
            }

            await _orderServicesCarWash.SaveOrder(order);
        }
예제 #4
0
        public async Task <ActionResult> CloseOrder(int?id, bool selectionStatus = true, bool AdminError = true)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var Order          = Mapper.Map <OrderServicesCarWashView>(await _order.GetId(id));
            var Services       = Mapper.Map <IEnumerable <ServisesCarWashOrderView> >(await _servisesCarWash.GetAllId(id));
            var getAllAdminDay = Mapper.Map <IEnumerable <CarWashWorkersView> >(await _employeesFacade.ListOfEmployeesForService());

            ViewBag.Brigade      = Mapper.Map <IEnumerable <CarWashWorkersView> >(await _employeesFacade.ListOfEmployeesForService(Order.typeOfOrder.Value));
            ViewBag.TeamLead     = new SelectList(getAllAdminDay.Where(x => x.IdPosition <= 2), "id", "Name");
            ViewBag.Adminstrator = new SelectList(getAllAdminDay.Where(x => x.IdPosition == 4), "id", "Name");

            Price = Services.Sum(x => x.Price);
            var typeServese = Services.FirstOrDefault();

            ViewBag.Services      = Services;
            ViewBag.CauntServices = Services.Count();

            if (AdminError == false)
            {
                ViewBag.AdminError = AdminError;
            }

            if (typeServese != null)
            {
                ViewBag.TypeService = typeServese.Detailings.IdTypeService;
            }
            else
            {
                ViewBag.TireServices = Mapper.Map <IEnumerable <AdditionalTireStorageServicesView> >(await _additionalTireStorageServices.GetOrderId(id.Value));
                ViewBag.TypeService  = 2;
            }

            ViewBag.Price = Price;

            if (selectionStatus == false)
            {
                ViewBag.SelectionStatus = selectionStatus;
            }

            TempData["ServicesType"] = Services;

            if (Order.ClientsOfCarWash.discont > 0)
            {
                ViewBag.Total = _orderServices.Discont(Order.ClientsOfCarWash.discont, Price);
            }
            else
            {
                ViewBag.Total = Price;
            }

            if (Order == null)
            {
                return(HttpNotFound());
            }

            return(View(Order));
        }