예제 #1
0
        public async Task <List <IncomeModel> > ServiceIncome(IEnumerable <OrderServicesCarWashBll> orderServicesCarWashes)
        {
            var typeServices = await _typeOfOrderServices.GetTableAll();

            var financServises = new List <IncomeModel>();

            foreach (var itemServ in typeServices)
            {
                if (orderServicesCarWashes.Any(x => x.typeOfOrder == itemServ.IdTypeOfOrder))
                {
                    var orderServices = orderServicesCarWashes.Where(x => x.typeOfOrder == itemServ.IdTypeOfOrder);
                    if (itemServ.IdTypeOfOrder != 5)
                    {
                        var awaitingPaymentStatus = Math.Round(orderServices.Where(x => x.StatusOrder == 4).Sum(s => s.DiscountPrice).Value, 1);
                        var inWorkStatus          = Math.Round(orderServices.Where(x => x.StatusOrder == 1).Sum(s => s.DiscountPrice).Value, 1);

                        financServises.Add(new IncomeModel
                        {
                            IdIncome         = itemServ.IdTypeOfOrder,
                            ServicesOfInvome = itemServ.nameOrder,
                            CountServices    = orderServices.Count(),
                            SumOfIncome      = Math.Round(orderServices.Where(x => x.StatusOrder == 2).Sum(x => x.DiscountPrice).Value, 1),
                            SumNoCash        = Math.Round(orderServices.Where(x => x.StatusOrder == 2 && x.PaymentState == (int)PaymentMethod.nonСash).Sum(s => s.DiscountPrice).Value, 1),
                            SumCash          = Math.Round(orderServices.Where(x => x.StatusOrder == 2 && x.PaymentState == (int)PaymentMethod.cash).Sum(s => s.DiscountPrice).Value, 1),
                            AwaitingPayment  = awaitingPaymentStatus + inWorkStatus,
                            SumTotalIncome   = Math.Round(orderServices.Where(x => x.StatusOrder <= 2).Sum(x => x.DiscountPrice).Value + orderServices.Where(x => x.StatusOrder == 4).Sum(s => s.DiscountPrice).Value, 1)
                        });
                    }
                    else
                    {
                        financServises.Add(new IncomeModel
                        {
                            IdIncome         = itemServ.IdTypeOfOrder,
                            ServicesOfInvome = itemServ.nameOrder,
                            CountServices    = orderServices.Count(),
                            SumOfIncome      = Math.Round(orderServices.Where(x => x.StatusOrder == 2 || x.StatusOrder == 5).Sum(x => x.DiscountPrice).Value, 1),
                            SumNoCash        = Math.Round(orderServices.Where(x => x.StatusOrder == 2 || x.StatusOrder == 5 && x.PaymentState == (int)PaymentMethod.nonСash).Sum(s => s.DiscountPrice).Value, 1),
                            SumCash          = Math.Round(orderServices.Where(x => x.StatusOrder == 2 || x.StatusOrder == 5 && x.PaymentState == (int)PaymentMethod.cash).Sum(s => s.DiscountPrice).Value, 1),
                            AwaitingPayment  = Math.Round(orderServices.Where(x => x.StatusOrder == 4 || x.StatusOrder == 1).Sum(s => s.DiscountPrice).Value, 1),
                            SumTotalIncome   = Math.Round(orderServices.Where(x => x.StatusOrder == 2 || x.StatusOrder == 5).Sum(x => x.DiscountPrice).Value + orderServices.Where(x => x.StatusOrder == 4).Sum(s => s.DiscountPrice).Value, 1)
                        });
                    }
                }
            }

            return(financServises);
        }
        private int TypeServices(string name)
        {
            var typeServices      = Task.Run <IEnumerable <TypeOfOrderBll> >(async() => await _typeOfOrderServices.GetTableAll());
            var typeServiesResult = typeServices.Result;
            var idTypeServises    = typeServiesResult.FirstOrDefault(x => x.nameOrder.Contains(name.Trim()));

            return(idTypeServises.IdTypeOfOrder);
        }