Exemplo n.º 1
0
        public async Task <ActionResult> ServicesDelete(int?idOrder, int?discont, int idServices = 0)
        {
            if (idServices != 0)
            {
                await _servisesCarWash.ServicesDelete(idServices, nameof(OrderController));

                await _order.RecountOrder(idOrder.Value, discont);

                var order = await _order.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("OrderInfo"));
            }
            else
            {
                await _order.DeleteOrder(idOrder.Value);

                return(RedirectToAction("Index"));
            }
        }
        public async Task <ActionResult> CloseOrder(List <string> idBrigade, int BrigadeOrder, int?idPaymentState, int?idStatusOrder, int?idOrder, int?idAdmin, int?idTeamLead)
        {
            if (BrigadeOrder == 0 && idBrigade != null)
            {
                if (idStatusOrder != 1 && idPaymentState != 3 || idStatusOrder == 4 && idPaymentState == 3)
                {
                    var typeServese = 2;
                    await _wageModules.ChangeOrderStatusAndPayroll(idOrder.Value, typeServese, idPaymentState.Value, idStatusOrder.Value, idAdmin, idTeamLead, idBrigade);
                }

                if (idStatusOrder == 3)
                {
                    await _orderServices.DeleteOrder(idOrder.Value);
                }

                return(RedirectToAction("OrderTireStorage", "Order", new RouteValueDictionary(new
                {
                    typeOfOrder = (int)TypeOfOrder.TireFitting,
                    statusOrder = (int)StatusOrder.InWork
                })));
            }
            else if (BrigadeOrder == 1)
            {
                if (idStatusOrder != 1 && idPaymentState != 3 || idStatusOrder == 4 && idPaymentState == 3)
                {
                    var order = await _orderServices.GetId(idOrder);

                    await _wageModules.CloseOrder(idPaymentState.Value, order, idStatusOrder.Value);
                }

                if (idStatusOrder == 3)
                {
                    await _orderServices.DeleteOrder(idOrder.Value);
                }

                return(RedirectToAction("OrderTireStorage", "Order", new RouteValueDictionary(new
                {
                    typeOfOrder = (int)TypeOfOrder.TireFitting,
                    statusOrder = (int)StatusOrder.InWork
                })));
            }

            return(View());
        }
Exemplo n.º 3
0
        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());
        }
        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"));
        }