private List <XmlFileManagementFormViewModel> GetData(XmlFileManagementIndexViewModel filter = null) { GetXmlLogByParamInput input = new GetXmlLogByParamInput(); List <XML_LOGSDto> dbData; if (filter != null) { input.DateFrom = filter.DateFrom; input.DateTo = filter.DateTo; } dbData = _xmlFileLogBll.GetXmlLogByParam(input); return(Mapper.Map <List <XmlFileManagementFormViewModel> >(dbData)); }
public List <XML_LOGSDto> GetXmlLogByParam(GetXmlLogByParamInput input) { Expression <Func <XML_LOGS, bool> > queryFilter = PredicateHelper.True <XML_LOGS>(); if (input.DateFrom.HasValue) { input.DateFrom = new DateTime(input.DateFrom.Value.Year, input.DateFrom.Value.Month, input.DateFrom.Value.Day, 0, 0, 0); queryFilter = queryFilter.And(c => c.LAST_ERROR_TIME >= input.DateFrom); } if (input.DateTo.HasValue) { input.DateFrom = new DateTime(input.DateTo.Value.Year, input.DateTo.Value.Month, input.DateTo.Value.Day, 23, 59, 59); queryFilter = queryFilter.And(c => c.LAST_ERROR_TIME <= input.DateTo); } Func <IQueryable <XML_LOGS>, IOrderedQueryable <XML_LOGS> > orderByFilter = n => n.OrderByDescending(z => z.LAST_ERROR_TIME); var result = _repository.Get(queryFilter, orderByFilter, "").ToList(); return(Mapper.Map <List <XML_LOGSDto> >(result.ToList())); }