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());
        }
Esempio n. 2
0
        public async Task <ActionResult> CloseOrder(List <string> idBrigade, int idOrder, int idPaymentState, int idStatusOrder, int?typeServese, int?idAdmin, int?idTeamLead)
        {
            var brigadeAdmin = await _brigade.AdminTrue(DateTime.Now, 2);

            bool checkingPerformer = idBrigade != null && idAdmin != null && idTeamLead != null;

            if (brigadeAdmin)
            {
                if (checkingPerformer && idPaymentState != 3 && idStatusOrder == 2) //Выполнен
                {
                    await _wageModules.ChangeOrderStatusAndPayroll(idOrder, typeServese.Value, idPaymentState, idStatusOrder, idAdmin, idTeamLead, idBrigade);
                }
                else if (checkingPerformer && idStatusOrder == 4) //Ожидает оплаты
                {
                    await _wageModules.ChangeOrderStatusAndPayroll(idOrder, typeServese.Value, idPaymentState, idStatusOrder, idAdmin, idTeamLead, idBrigade);
                }
                else if (idStatusOrder == 5 && idPaymentState != 3)
                {
                    var statusBrigade = await _orderCarWashWorkers.GetTableInclud(idOrder);

                    if (statusBrigade.Any(x => x.IdOrder == idOrder))
                    {
                        idStatusOrder = 2;
                        var order = await _order.GetId(idOrder);

                        await _wageModules.CloseOrder(idPaymentState, order, idStatusOrder);
                    }
                    else
                    {
                        return(RedirectToAction("CloseOrder", "Order", new RouteValueDictionary(new
                        {
                            id = idOrder,
                            selectionStatus = false
                        })));
                    }
                }
                else if (idStatusOrder == 3)
                {
                    var order = await _order.GetId(idOrder);

                    await _wageModules.CloseOrder(idPaymentState, order, idStatusOrder);
                }
                else
                {
                    return(RedirectToAction("CloseOrder", "Order", new RouteValueDictionary(new
                    {
                        id = idOrder,
                        selectionStatus = false
                    })));
                }
            }
            else
            {
                return(RedirectToAction("CloseOrder", "Order", new RouteValueDictionary(new
                {
                    id = idOrder,
                    AdminError = false
                })));
            }

            return(RedirectToAction("Index"));
        }