示例#1
0
 public BaseResponse <NursingRec> SaveNursingRec(NursingRec request)
 {
     if (request.Id == 0)
     {
         request.CreateBy   = SecurityHelper.CurrentPrincipal.EmpNo;
         request.CreateDate = DateTime.Now;
         request.OrgId      = SecurityHelper.CurrentPrincipal.OrgId;
     }
     return(base.Save <LTC_NURSINGREC, NursingRec>(request, (q) => q.ID == request.Id));
 }
示例#2
0
        public BaseResponse <IList <NursingRec> > QueryNursingRec(BaseRequest <NursingRecFilter> request)
        {
            BaseResponse <IList <NursingRec> > response = new BaseResponse <IList <NursingRec> >();
            var q = from n in unitOfWork.GetRepository <LTC_NURSINGREC>().dbSet
                    join e in unitOfWork.GetRepository <LTC_EMPFILE>().dbSet on n.RECORDBY equals e.EMPNO into res
                    from re in res.DefaultIfEmpty()
                    select new
            {
                NursingRec = n,
                EmpName    = re.EMPNAME
            };

            if (request.Data.FeeNo.HasValue)
            {
                q = q.Where(m => m.NursingRec.FEENO == request.Data.FeeNo);
            }
            if (request.Data.RegNo.HasValue)
            {
                q = q.Where(m => m.NursingRec.REGNO == request.Data.RegNo);
            }
            q = q.OrderByDescending(m => m.NursingRec.CREATEDATE);
            response.RecordsCount = q.Count();
            Action <IList> mapperResponse = (IList list) =>
            {
                response.Data = new List <NursingRec>();
                foreach (dynamic item in list)
                {
                    NursingRec newItem = Mapper.DynamicMap <NursingRec>(item.NursingRec);
                    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(NursingRec baseRequest)
        {
            var response = service.SaveNursingRec(baseRequest);

            return(Ok(response));
        }