Esempio n. 1
0
        public List <LeaseCostByFunctionDto> GetLeaseCostByFunctionData(LeaseCostFuncGetByParamInput filter)
        {
            var data = _ExecSummService.GetAllLeaseCostByFunction(filter);

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

            var groupData = listData.GroupBy(x => new { x.REGION, x.FUNCTION, x.REPORT_MONTH, x.REPORT_YEAR })
                            .Select(p => new LeaseCostByFunctionDto()
            {
                REGION           = p.FirstOrDefault().REGION,
                FUNCTION         = p.FirstOrDefault().FUNCTION,
                REPORT_MONTH     = p.FirstOrDefault().REPORT_MONTH,
                REPORT_YEAR      = p.FirstOrDefault().REPORT_YEAR,
                TOTAL_LEASE_COST = p.Sum(c => c.TOTAL_LEASE_COST)
            }).ToList();

            return(groupData);
        }
Esempio n. 2
0
        public List <LEASE_COST_BY_FUNC_REPORT_DATA> GetAllLeaseCostByFunction(LeaseCostFuncGetByParamInput filter)
        {
            Expression <Func <LEASE_COST_BY_FUNC_REPORT_DATA, bool> > queryFilter = PredicateHelper.True <LEASE_COST_BY_FUNC_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()));
                    }
                }
            }

            return(_leaseCostByFuncRepository.Get(queryFilter, null, "").ToList());
        }