Example #1
0
        // Начисление ЗП и изменения статуса заказа
        public async Task ChangeOrderStatusAndPayroll(int idOrder, int typeServese, int idPaymentState, int idStatusOrder, int?idAdmin, int?idTeamLead, List <string> idBrigade = null)
        {
            var order = await _orderServicesCarWash.GetId(idOrder);

            var converter = idBrigade == null ? await _orderCarWashWorkers.GetTableInclud(idOrder) : ConvertListToIEnumerable(idBrigade);

            // Close Order
            await CloseOrder(idPaymentState, order, idStatusOrder);

            // Начисление заработной платы сотрудникам
            await Payroll(order, converter, typeServese);

            // Начисление заработной платы Администраору
            await AdminWage(order, (int)TypeService.Sales, idAdmin.Value);

            // Наичление заработной платы Тим лидеру
            await AdminWage(order, typeServese, idTeamLead.Value);
        }
        public async Task UpdateServises(int?idOrder, int idStatusOrder, int idPaymentState)
        {
            var order = await _orderServices.GetId(idOrder);

            order.ClosingData  = DateTime.Now;
            order.PaymentState = idPaymentState;
            order.StatusOrder  = idStatusOrder;

            await _orderServices.SaveOrder(order);
        }
        // GET: OrderCarpetWashing/Edit/5
        public async Task <ActionResult> AboutOrder(int?idOrder, int?idClient, int?idPage)
        {
            if (idClient == null && idOrder == null)
            {
                var httpstatusCode = new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(RedirectToAction("OrderCarpetWashing"));
            }

            OrderCarpetWashingView orderCarpetWashingView = Mapper.Map <OrderCarpetWashingView>(await _orderCarpetWashingServices.SelectId(idOrder));
            ClientInfoView         clientInfoView         = Mapper.Map <ClientInfoView>(await _clientInfo.ClientInfoGetId(idClient));

            var brigadeForToday = Mapper.Map <IEnumerable <BrigadeForTodayView> >(await _brigadeForToday.GetDateTimeNow());
            var orderServices   = Mapper.Map <OrderServicesCarWashView>(await _orderServicesCarWash.GetId(orderCarpetWashingView.orderServicesCarWashId));
            var test            = orderServices.OrderCarWashWorkers.FirstOrDefault(x => x.IdOrder == orderCarpetWashingView.orderServicesCarWashId);
            var getAllAdminDay  = Mapper.Map <IEnumerable <CarWashWorkersView> >(await _employeesFacade.ListOfEmployeesForService());

            ViewBag.Brigade      = Mapper.Map <IEnumerable <CarWashWorkersView> >(await _employeesFacade.ListOfEmployeesForService(3));
            ViewBag.Sum          = orderServices.DiscountPrice;
            ViewBag.BrigateOrder = test;
            ViewBag.ResultPay    = orderServices.PaymentState;

            ViewBag.TeamLead     = new SelectList(getAllAdminDay.Where(x => x.IdPosition <= 2), "id", "Name");
            ViewBag.Adminstrator = new SelectList(getAllAdminDay.Where(x => x.IdPosition == 4), "id", "Name");

            ViewBag.IdPage     = idPage;
            ViewBag.ClientInfo = clientInfoView;

            var paymentSate = Mapper.Map <IEnumerable <PaymentStateView> >(await _paymentState.GetTableAll());

            ViewBag.PaymentState       = new SelectList(paymentSate, "Id", "PaymentState1");
            ViewBag.PaymentStateResult = orderServices.PaymentState;
            ViewBag.ClientId           = idClient;

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

            return(View(orderCarpetWashingView));
        }
        public async Task <ActionResult> InfoOrder(int?idOrder, int?idClient, int?idCompany, int?idAdmin, int idStatusOrder, int idPaymentState)
        {
            bool typePaymentState = idPaymentState == 1 || idPaymentState == 2 ? true : false;

            if (idOrder == null || idClient == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (idCompany == null || idStatusOrder == 1)
            {
                return(RedirectToAction("Color", "InfoOrder", new RouteValueDictionary(new { idOrder = idOrder, idClient = idClient })));
            }

            if (idStatusOrder == 4 && idPaymentState == 3)
            {
                await _orderColor.UpdateServises(idOrder, idStatusOrder, idPaymentState);

                return(RedirectToAction("Index", "Color"));
            }

            if (idStatusOrder == 2 && typePaymentState)
            {
                await _orderColor.UpdateServises(idOrder, idStatusOrder, idPaymentState);

                // Начисление заработной платы Администраору
                var order = await _orderServices.GetId(idOrder);

                await _wageModules.AdminWage(order, (int)TypeService.Sales, idAdmin.Value);

                // Начисления процента исполнителю
                await _orderСompany.SaveOrder(idOrder, idCompany, idAdmin, (int)TypeService.DryCleaningKohler, order.DiscountPrice);

                return(RedirectToAction("Index", "Color"));
            }

            if (idStatusOrder == 3 && idOrder != null)
            {
                await _orderServices.DeleteOrder(idOrder.Value);

                return(RedirectToAction("Index", "Color"));
            }

            return(View());
        }
Example #5
0
        public async Task <ActionResult> InfoOrderTireStorage(int?idOrder)
        {
            if (idOrder == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var order       = Mapper.Map <OrderServicesCarWashView>(await _orderServicesCarWash.GetId(idOrder));
            var tireStorage = Mapper.Map <TireStorageView>(await _tireStorage.GetOrderId(idOrder.Value));

            if (tireStorage != null && tireStorage.RelatedOrders != null)
            {
                getAdditionalTireStorageServices = Mapper.Map <IEnumerable <AdditionalTireStorageServicesView> >(await _additionalTireStorageServices.GetOrderId(tireStorage.RelatedOrders.Value));
            }

            var client = Mapper.Map <ClientsOfCarWashView>(await _clientsOfCarWash.GetId(order.IdClientsOfCarWash));

            ViewBag.Order = order;
            ViewBag.AdditionalTireStorageServices = getAdditionalTireStorageServices;
            ViewBag.Client = client;

            DateTime dateClose = tireStorage.dateOfAdoption.Value;
            double?  sum       = 0;

            if (getAdditionalTireStorageServices != null)
            {
                sum = getAdditionalTireStorageServices.Sum(x => x.Price);
            }

            ViewBag.PaymentState = order.PaymentState;
            ViewBag.StatusOrder  = order.StatusOrder;

            ViewBag.CloseDate     = dateClose.AddMonths(tireStorage.storageFee.storageTime.Value);
            ViewBag.Sum           = tireStorage.storageFee.amount + sum + tireStorage.serviceCostTirePackages;
            ViewBag.SumAdditional = sum + tireStorage.serviceCostTirePackages;

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

            return(View(tireStorage));
        }
        public async Task <ActionResult> OrderPreview(List <double> carBody, List <int> id, List <int> sum, List <string> idBrigade, double total, int?idOrder = null)
        {
            if (idOrder == null)
            {
                int service = 0;

                if (TempData.ContainsKey("typeServices"))
                {
                    service = Convert.ToInt32(TempData["typeServices"]);
                }

                await _orderServicesInsert.InsertOrders(service, carBody, id, sum, total);
            }
            else
            {
                await _orderServicesInsert.InsertOrders(carBody, id, sum, total, idOrder);

                var order = await _orderServicesInsert.GetId(idOrder);

                if (await _wageModules.SalaryForTheCurrentOrder(order.Id))
                {
                    // Начисление заработной платы сотрудникам
                    var selectEmployees = _wageModules.GetCurrentEmployees(order);
                    await _wageModules.Payroll(order, selectEmployees, order.typeOfOrder.Value);

                    // Начисление заработной платы Администраору
                    var selectAdmin = _wageModules.GetCurrentAdministrator((int)TypeService.Sales, order);
                    await _wageModules.AdminWage(order, (int)TypeService.Sales, selectAdmin, true);

                    // Наичление заработной платы Тим лидеру
                    var selectTeamLead = _wageModules.GetCurrentAdministrator(order.typeOfOrder.Value, order);
                    await _wageModules.AdminWage(order, order.typeOfOrder.Value, selectTeamLead, true);
                }
            }

            return(RedirectToAction("Index", "Order"));
        }
Example #7
0
        // GET: Order/Details/5
        public async Task <ActionResult> OrderInfo(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var OrderInfo = Mapper.Map <OrderServicesCarWashView>(await _order.GetId(id));
            var info      = Mapper.Map <IEnumerable <ServisesCarWashOrderView> >(await _servisesCarWash.GetAllId(id));

            ViewBag.ServisesInfo  = info;
            ViewBag.DiscontClient = OrderInfo.ClientsOfCarWash.discont;
            ViewBag.Status        = new SelectList(Mapper.Map <IEnumerable <StatusOrderView> >(await _statusOrder.GetTableAll()), "Id", "StatusOrder1");

            if (info.Any(x => x.Detailings.IdTypeService == 1))
            {
                ViewBag.ServisesId = 1;
                ViewBag.ServersKey = id;
            }
            else
            {
                ViewBag.ServisesId = 2;
                ViewBag.ServersKey = id;
            }

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

            if (TempData.ContainsKey("PageSettings"))
            {
                ViewBag.Brigade = Mapper.Map <IEnumerable <BrigadeForTodayView> >(await _brigade.GetDateTimeNow());
            }

            return(View(OrderInfo));
        }
        public async Task <ActionResult> OrderPreview(List <string> idBrigade, double Total, int idPaymentState, int idStatusOrder, int?idAdmin, int?idTeamLead)
        {
            CreateOrderView createOrderView = new CreateOrderView();

            int idOrder = 0;

            if (idStatusOrder == (int)StatusOrder.Completed && idBrigade == null)
            {
                TempData.Keep("CreateOrder");

                return(RedirectToAction("OrderPreview", "TireChangeService", new RouteValueDictionary(new
                {
                    Error = true
                })));
            }

            if (TempData.ContainsKey("CreateOrder"))
            {
                createOrderView = (CreateOrderView)TempData["CreateOrder"];

                double priceListTireFittingAdditionalsSum = 0;

                if (createOrderView.priceListTireFittingAdditionals != null)
                {
                    priceListTireFittingAdditionalsSum = createOrderView.priceListTireFittingAdditionals.Sum(x => x.TheCost).Value;
                }

                if (createOrderView.numberOfTires != 0 || createOrderView.priceListTireFittings != null)
                {
                    double TotalSum = SumTireChangeService(createOrderView.priceListTireFittings, createOrderView.numberOfTires.Value) + priceListTireFittingAdditionalsSum;
                    idOrder = await _createOrder.SaveOrderTireFitting(TotalSum, Total, idPaymentState, idStatusOrder, createOrderView.client.Value, 4);
                }
                else if (priceListTireFittingAdditionalsSum != 0)
                {
                    idOrder = await _createOrder.SaveOrderTireFitting(priceListTireFittingAdditionalsSum, Total, idPaymentState, idStatusOrder, createOrderView.client, 4);
                }

                if (createOrderView.priceListTireFittingAdditionals != null)
                {
                    List <PriceListTireFittingAdditionalServicesBll> priceListTireFittings = new List <PriceListTireFittingAdditionalServicesBll>();
                    priceListTireFittings = Mapper.Map <List <PriceListTireFittingAdditionalServicesView>, List <PriceListTireFittingAdditionalServicesBll> >(createOrderView.priceListTireFittingAdditionals);

                    await _createOrder.SeveTireService(createOrderView.client, idOrder, priceListTireFittings);
                }

                if (createOrderView.priceListTireFittings != null)
                {
                    List <PriceListTireFittingBll> listTireFittingBlls = new List <PriceListTireFittingBll>();
                    listTireFittingBlls = Mapper.Map <List <PriceListTireFittingView>, List <PriceListTireFittingBll> >(createOrderView.priceListTireFittings);

                    await _createOrder.SaveTireChangeService(idOrder, createOrderView.numberOfTires.Value, listTireFittingBlls);
                }

                var order = await _orderServices.GetId(idOrder);

                if (idBrigade != null)
                {
                    // Начисление заработной платы сотрудникам
                    await _wageModules.Payroll(order, _wageModules.ConvertListToIEnumerable(idBrigade), (int)TypeService.TireFitting);
                }

                if (idAdmin != null)
                {
                    // Начисление заработной платы Администраору
                    await _wageModules.AdminWage(order, (int)TypeService.Sales, idAdmin.Value);
                }

                if (idTeamLead != null)
                {
                    // Наичление заработной платы Тим лидеру
                    await _wageModules.AdminWage(order, (int)TypeService.TireFitting, idTeamLead.Value);
                }

                TempData.Remove("CreateOrder");

                return(RedirectToAction("../Order/Index"));
            }

            TempData.Keep("CreateOrder");

            return(View());
        }