public CDataResults <CWmtRsvrListDto> GetWmtRsvr(CWmtRsvrInput input) { //Check Ip & customer if (!checkIPandCustomer(input.customerId)) { AddVisitRecord(input.customerId, Entities.VisitRecordFlag.Black); return(new CDataResults <CWmtRsvrListDto>() { IsSuccess = false, ErrorMessage = "Validation failed.", Data = null }); } //Extract data from DB var query = this._wmtRsvrRepository.GetAll(); if (input.pageNumber.HasValue && input.pageNumber.Value > 0 && input.pageSize.HasValue) { query = query.OrderBy(r => r.Id).Take(input.pageSize.Value * input.pageNumber.Value).Skip(input.pageSize.Value * (input.pageNumber.Value - 1)); } var result = query.ToList().MapTo <List <CWmtRsvrListDto> >(); //Add visit record AddVisitRecord(input.customerId, Entities.VisitRecordFlag.White); return(new CDataResults <CWmtRsvrListDto>() { IsSuccess = true, ErrorMessage = null, Data = result }); }
public CDataResults <CWmtRsvrDetailListDto> GetWmtRsvrDetail(CWmtRsvrInput input) { //Check Ip & customer if (!checkIPandCustomer(input.customerId)) { AddVisitRecord(input.customerId, Entities.VisitRecordFlag.Black); return(new CDataResults <CWmtRsvrDetailListDto>() { IsSuccess = false, ErrorMessage = "Validation failed.", Data = null }); } //Extract data from DB var query = from r in _wmtRsvrRepository.GetAll() join s in _stnInfoBRepository.GetAll() on r.stcd equals s.areaCode join res in _relationReposity.GetAll() on s.Id equals res.site_id where res.customer_id == input.customerId orderby r.collecttime select new CWmtRsvrDetailListDto { areaCode = s.areaCode, areaName = s.areaName, stcd = r.stcd, paravalue = r.paravalue, collecttime = r.collecttime, systemtime = r.systemtime, uniquemark = r.uniquemark, gentm = r.gentm }; if (input.fromTime != null) { query = query.Where(r => r.collecttime > input.fromTime); } if (input.toTime != null) { query = query.Where(r => r.collecttime < input.toTime); } if (!string.IsNullOrEmpty(input.stcd)) { query = query.Where(r => r.stcd == input.stcd); } if (input.pageNumber.HasValue && input.pageNumber.Value > 0 && input.pageSize.HasValue) { query = query.OrderByDescending(r => r.collecttime).Take(input.pageSize.Value * input.pageNumber.Value).Skip(input.pageSize.Value * (input.pageNumber.Value - 1)); } var result = query.ToList(); //Add visit record AddVisitRecord(input.customerId, Entities.VisitRecordFlag.White); return(new CDataResults <CWmtRsvrDetailListDto>() { IsSuccess = true, ErrorMessage = null, Data = result, Total = query.Count() }); }