Ejemplo n.º 1
0
        public IHttpActionResult Post(BedSoreChgrec request)
        {
            request.CreateBy   = SecurityHelper.CurrentPrincipal.LoginName;
            request.CreateDate = DateTime.Now;
            var response = service.SaveBedSoreChgrec(request);

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public BaseResponse <IList <BedSoreChgrec> > QueryBedSoreChgrec(BaseRequest <BedSoreChgrecFilter> request)
        {
            //var response = base.Query<LTC_BEDSORECHGREC, BedSoreChgrec>(request, (q) =>
            //{
            //    if (request.Data.Seq!=null)
            //    {
            //        q = q.Where(m => m.SEQ == request.Data.Seq);
            //    }
            //    q = q.OrderByDescending(m => m.CREATEDATE);
            //    return q;
            //});
            //return response;

            BaseResponse <IList <BedSoreChgrec> > response = new BaseResponse <IList <BedSoreChgrec> >();
            var q = from n in unitOfWork.GetRepository <LTC_BEDSORECHGREC>().dbSet
                    join e in unitOfWork.GetRepository <LTC_EMPFILE>().dbSet on n.NURSE equals e.EMPNO into res
                    from re in res.DefaultIfEmpty()
                    select new
            {
                BedSoreChgrec = n,
                NurseName     = re.EMPNAME,
            };

            q = q.Where(m => m.BedSoreChgrec.SEQ == request.Data.Seq);
            q = q.OrderByDescending(m => m.BedSoreChgrec.CREATEDATE);
            response.RecordsCount = q.Count();
            Action <IList> mapperResponse = (IList list) =>
            {
                response.Data = new List <BedSoreChgrec>();
                foreach (dynamic item in list)
                {
                    BedSoreChgrec newItem = Mapper.DynamicMap <BedSoreChgrec>(item.BedSoreChgrec);
                    newItem.NurseName = item.NurseName;
                    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);
        }
Ejemplo n.º 3
0
 public BaseResponse <BedSoreChgrec> SaveBedSoreChgrec(BedSoreChgrec request)
 {
     return(base.Save <LTC_BEDSORECHGREC, BedSoreChgrec>(request, (q) => q.ID == request.Id));
 }