Exemplo n.º 1
0
        public List <ODOMETER_REPORT_DATA> GetAllOdometer(OdometerGetByParamInput filter)
        {
            Expression <Func <ODOMETER_REPORT_DATA, bool> > queryFilter = PredicateHelper.True <ODOMETER_REPORT_DATA>();

            if (filter != null)
            {
                if (filter.MonthFrom > 0)
                {
                    queryFilter = queryFilter.And(c => c.REPORT_MONTH >= filter.MonthFrom);
                }
                if (filter.MonthTo > 0)
                {
                    queryFilter = queryFilter.And(c => c.REPORT_MONTH <= filter.MonthTo);
                }
                if (filter.YearFrom > 0)
                {
                    queryFilter = queryFilter.And(c => c.REPORT_YEAR >= filter.YearFrom);
                }
                if (filter.YearTo > 0)
                {
                    queryFilter = queryFilter.And(c => c.REPORT_YEAR <= filter.YearTo);
                }
                if (!string.IsNullOrEmpty(filter.Region))
                {
                    queryFilter = queryFilter.And(c => c.REGION.ToUpper() == filter.Region.ToUpper());
                }
                if (!string.IsNullOrEmpty(filter.Function))
                {
                    var listFunction = filter.Function.ToUpper().Split(',').ToList();

                    if (listFunction.Contains("OTHERS"))
                    {
                        queryFilter = queryFilter.And(c => listFunction.Contains(c.FUNCTION.ToUpper()) ||
                                                      (c.FUNCTION.ToUpper() != "SALES" && c.FUNCTION.ToUpper() != "MARKETING" && c.FUNCTION.ToUpper() != "OPERATIONS"));
                    }
                    else
                    {
                        queryFilter = queryFilter.And(c => listFunction.Contains(c.FUNCTION.ToUpper()));
                    }
                }
                if (!string.IsNullOrEmpty(filter.VehicleType))
                {
                    queryFilter = queryFilter.And(c => c.VEHCILE_TYPE.ToUpper() == filter.VehicleType.ToUpper());
                }
            }

            return(_odometerRepository.Get(queryFilter, null, "").ToList());
        }
Exemplo n.º 2
0
        public List <OdometerDto> GetOdometerData(OdometerGetByParamInput filter)
        {
            var data = _ExecSummService.GetAllOdometer(filter);

            var listData = Mapper.Map <List <OdometerDto> >(data);

            var groupData = listData.GroupBy(x => new { x.REGION, x.FUNCTION, x.VEHICLE_TYPE, x.REPORT_MONTH, x.REPORT_YEAR })
                            .Select(p => new OdometerDto()
            {
                REGION       = p.FirstOrDefault().REGION,
                FUNCTION     = p.FirstOrDefault().FUNCTION,
                VEHICLE_TYPE = p.FirstOrDefault().VEHICLE_TYPE,
                REPORT_MONTH = p.FirstOrDefault().REPORT_MONTH,
                REPORT_YEAR  = p.FirstOrDefault().REPORT_YEAR,
                TOTAL_KM     = p.Max(c => c.TOTAL_KM)
            }).ToList();

            return(groupData);
        }