public BaseResponse <InfectionInd> SaveInfectionInd(InfectionInd request) { if (request.SeqNo == 0) { request.OrgId = SecurityHelper.CurrentPrincipal.OrgId; } return(base.Save <LTC_INFECTIONIND, InfectionInd>(request, (q) => q.SEQNO == request.SeqNo)); }
public BaseResponse <IList <InfectionInd> > QueryInfectionInd(BaseRequest <InfectionIndFilter> request) { BaseResponse <IList <InfectionInd> > response = new BaseResponse <IList <InfectionInd> >(); var q = from n in unitOfWork.GetRepository <LTC_INFECTIONIND>().dbSet join e in unitOfWork.GetRepository <LTC_EMPFILE>().dbSet on n.RECORDBY equals e.EMPNO into res from re in res.DefaultIfEmpty() select new { InfectionInd = n, EmpName = re.EMPNAME }; if (request != null && !string.IsNullOrEmpty(request.Data.OrgId)) { q = q.Where(m => m.InfectionInd.ORGID == request.Data.OrgId); } if (request != null && !string.IsNullOrEmpty(request.Data.FeeNo.ToString())) { q = q.Where(m => m.InfectionInd.FEENO == request.Data.FeeNo); } if (request != null && !string.IsNullOrEmpty(request.Data.RegNo.ToString())) { q = q.Where(m => m.InfectionInd.REGNO == request.Data.RegNo); } q = q.OrderByDescending(m => m.InfectionInd.RECDATE); response.RecordsCount = q.Count(); Action <IList> mapperResponse = (IList list) => { response.Data = new List <InfectionInd>(); foreach (dynamic item in list) { InfectionInd newItem = Mapper.DynamicMap <InfectionInd>(item.InfectionInd); newItem.RecordNameBy = item.EmpName; response.Data.Add(newItem); } }; if (request != null && request.PageSize > 0) { var list = q.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(); response.PagesCount = GetPagesCount(request.PageSize, response.RecordsCount); mapperResponse(list); } else { var list = q.ToList(); mapperResponse(list); } return(response); }
public IHttpActionResult Post(InfectionInd baseRequest) { var response = service.SaveInfectionInd(baseRequest); return(Ok(response)); }