示例#1
0
        public async Task <ActionResult> StatusOrder([Bind(Include = "StatusOrder")] OrderServicesCarWashView orderServices, int?OrderStatus)
        {
            if (orderServices.StatusOrder <= 4 && OrderStatus != null)
            {
                await _order.StatusOrder(OrderStatus, orderServices.StatusOrder.Value);

                return(RedirectToAction("Index"));
            }
            else if (orderServices.StatusOrder == 3 && OrderStatus != null)
            {
                await _order.DeleteOrder(OrderStatus.Value);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
 private async Task SaveOrderServices(OrderServicesCarWashView orderServices)
 {
     OrderServicesCarWashBll orderServicesBll = Mapper.Map <OrderServicesCarWashView, OrderServicesCarWashBll>(orderServices);
     await _orderServicesCarWash.SaveOrder(orderServicesBll);
 }
        public async Task <ActionResult> AboutOrder([Bind(Include = "orderCompletionDate")] OrderCarpetWashingView orderCarpetWashingView, int idOrderServis,
                                                    int idOrder, int?idPage, int?PaymentStateList, int?idClient, List <string> idBrigade = null, int?idAdmin = null, int?idTeamLead = null, bool orderDelete = false)
        {
            if (orderDelete)
            {
                await _orderServicesCarWash.DeleteOrder(idOrderServis);

                return(RedirectToAction("OrderCarpetWashing"));
            }

            if (idPage == 2)
            {
                if (PaymentStateList == 3)
                {
                    if (idBrigade != null && idTeamLead != null)
                    {
                        int idOrderServices = await EditOrderCarpetWashing(idOrder, idPage.Value, PaymentStateList.Value);

                        var order = await _orderServicesCarWash.GetId(idOrderServices);

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

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

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

                        OrderServicesCarWashView orderServices = Mapper.Map <OrderServicesCarWashView>(await _orderServicesCarWash.GetId(idOrderServices));
                        orderServices.PaymentState = PaymentStateList;
                        orderServices.StatusOrder  = (int)StatusOrder.AwaitingPayment;

                        if (orderServices.ClosingData == null)
                        {
                            orderServices.ClosingData = DateTime.Now;
                        }

                        await SaveOrderServices(orderServices);
                    }
                    else
                    {
                        int idOrderServices = await EditOrderCarpetWashing(idOrder, idPage.Value, PaymentStateList.Value);

                        OrderServicesCarWashView orderServices = Mapper.Map <OrderServicesCarWashView>(await _orderServicesCarWash.GetId(idOrderServices));
                        orderServices.PaymentState = PaymentStateList;
                        orderServices.StatusOrder  = (int)StatusOrder.AwaitingPayment;

                        if (orderServices.ClosingData == null)
                        {
                            orderServices.ClosingData = DateTime.Now;
                        }

                        await SaveOrderServices(orderServices);
                    }
                }
                else if (PaymentStateList == 1 || PaymentStateList == 2)
                {
                    if (idBrigade != null && idTeamLead != null)
                    {
                        int idOrderServices = await EditOrderCarpetWashing(idOrder, idPage.Value, PaymentStateList.Value);

                        var order = await _orderServicesCarWash.GetId(idOrderServices);

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

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

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

                        OrderServicesCarWashView orderServices = Mapper.Map <OrderServicesCarWashView>(await _orderServicesCarWash.GetId(idOrderServices));
                        orderServices.PaymentState = PaymentStateList;
                        orderServices.StatusOrder  = (int)StatusOrder.Completed;

                        if (orderServices.ClosingData == null)
                        {
                            orderServices.ClosingData = DateTime.Now;
                        }

                        await SaveOrderServices(orderServices);
                    }
                    else
                    {
                        int idOrderServices = await EditOrderCarpetWashing(idOrder, idPage.Value, PaymentStateList.Value);

                        OrderServicesCarWashView orderServices = Mapper.Map <OrderServicesCarWashView>(await _orderServicesCarWash.GetId(idOrderServices));
                        orderServices.PaymentState = PaymentStateList;
                        orderServices.StatusOrder  = (int)StatusOrder.Completed;

                        if (orderServices.ClosingData == null)
                        {
                            orderServices.ClosingData = DateTime.Now;
                        }

                        await SaveOrderServices(orderServices);
                    }
                }
                else
                {
                    return(RedirectToAction("AboutOrder", "OrderCarpetWashing", new RouteValueDictionary(new
                    {
                        idOrder = idOrder,
                        idClient = idClient,
                        idPage = idPage
                    })));
                }
            }

            return(RedirectToAction("OrderCarpetWashing"));
        }