public async Task <IEnumerable <OrderCarWashWorkersBll> > DetailsWages(int typeServices, int idEmployees, DateTime start, DateTime?finlDate, bool admin)
        {
            var result = await _wagesForCompleted.AnalyticsWages(start, finlDate.Value);

            if (admin)
            {
                var typeServisesResult = ChoiceOfServices.HoiceServiceType(typeServices);
                return(result.Where(x => x.IdCarWashWorkers == idEmployees && x.OrderServicesCarWash.typeOfOrder == typeServices));
            }
            else
            {
                return(_wagesForCompleted.EarningsPerEmployee(typeServices, idEmployees, result));
            }
        }
        private WagesForCompletedOrdersModels AnalyticsFormationWages(IEnumerable <OrderCarWashWorkersBll> orderCarWashes, IEnumerable <BonusToSalaryBll> bonus, IEnumerable <EmployeeRateBll> employees)
        {
            WagesForCompletedOrdersModels models = new WagesForCompletedOrdersModels();

            models.Detailing = new SalaryInformation();
            models.Detailing.SalaryAdministrator = Math.Round(orderCarWashes.Where(x => x.OrderServicesCarWash.typeOfOrder == ChoiceOfServices.HoiceServiceType(1)).Sum(s => s.Payroll).Value, 1);
            models.Detailing.TeamLeader          = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 1).Sum(s => s.Payroll).Value, 1);
            models.Detailing.SalaryEmployees     = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 4).Sum(s => s.Payroll).Value, 1);

            models.Washing = new SalaryInformation();
            models.Washing.SalaryAdministrator = Math.Round(orderCarWashes.Where(x => x.OrderServicesCarWash.typeOfOrder == ChoiceOfServices.HoiceServiceType(2)).Sum(s => s.Payroll).Value, 1);
            models.Washing.TeamLeader          = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 2).Sum(s => s.Payroll).Value, 1);
            models.Washing.SalaryEmployees     = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 5).Sum(s => s.Payroll).Value, 1);

            models.CarpetWashing = new SalaryInformation();
            models.CarpetWashing.SalaryAdministrator = Math.Round(orderCarWashes.Where(x => x.OrderServicesCarWash.typeOfOrder == ChoiceOfServices.HoiceServiceType(3)).Sum(s => s.Payroll).Value, 1);
            models.CarpetWashing.TeamLeader          = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 3).Sum(s => s.Payroll).Value, 1);
            models.CarpetWashing.SalaryEmployees     = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 6).Sum(s => s.Payroll).Value, 1);

            models.TireStorage = new SalaryInformation();
            models.TireStorage.SalaryAdministrator = Math.Round(orderCarWashes.Where(x => x.OrderServicesCarWash.typeOfOrder == ChoiceOfServices.HoiceServiceType(7)).Sum(s => s.Payroll).Value, 1);
            models.TireStorage.TeamLeader          = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 7).Sum(s => s.Payroll).Value, 1);
            models.TireStorage.SalaryEmployees     = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 8).Sum(s => s.Payroll).Value, 1);

            models.TireFitting = new SalaryInformation();
            models.TireFitting.SalaryAdministrator = Math.Round(orderCarWashes.Where(x => x.OrderServicesCarWash.typeOfOrder == ChoiceOfServices.HoiceServiceType(9)).Sum(s => s.Payroll).Value, 1);
            models.TireFitting.TeamLeader          = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 9).Sum(s => s.Payroll).Value, 1);
            models.TireFitting.SalaryEmployees     = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 10).Sum(s => s.Payroll).Value, 1);

            models.SalesAdministrator = new SalaryInformation();
            models.SalesAdministrator.SalaryAdministrator = Math.Round(orderCarWashes.Where(x => x.typeServicesId == 11).Sum(s => s.Payroll).Value, 1);

            models.SumBonusTOSalary = Math.Round(bonus.Sum(s => s.amount).Value, 1);
            models.SumEmployeeRate  = Math.Round(employees.Sum(s => s.wage).Value, 1);

            models.TotalSumWages = Math.Round(orderCarWashes.Sum(s => s.Payroll).Value) + models.SumBonusTOSalary + models.SumEmployeeRate;

            return(models);
        }