public List <NoVehicleWtcDto> GetNoOfVehicleWtcData(VehicleWtcGetByParamInput filter) { var data = _ExecSummService.GetAllNoVehicleWtc(filter); var listData = Mapper.Map <List <NoVehicleWtcDto> >(data); var groupData = listData.GroupBy(x => new { x.FUNCTION, x.REGIONAL, x.REPORT_MONTH, x.REPORT_YEAR }) .Select(p => new NoVehicleWtcDto() { REGIONAL = p.FirstOrDefault().REGIONAL, FUNCTION = p.FirstOrDefault().FUNCTION, REPORT_MONTH = p.FirstOrDefault().REPORT_MONTH, REPORT_YEAR = p.FirstOrDefault().REPORT_YEAR, NO_OF_VEHICLE = p.Sum(c => c.NO_OF_VEHICLE) }).ToList(); return(groupData); }
public List <NO_OF_WTC_VEHICLE_REPORT_DATA> GetAllNoVehicleWtc(VehicleWtcGetByParamInput filter) { Expression <Func <NO_OF_WTC_VEHICLE_REPORT_DATA, bool> > queryFilter = PredicateHelper.True <NO_OF_WTC_VEHICLE_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.Regional)) { queryFilter = queryFilter.And(c => c.REGIONAL.ToUpper() == filter.Regional.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())); } } } return(_noVehWtcRepository.Get(queryFilter, null, "").ToList()); }