Exemple #1
0
 public BaseResponse <UnPlanWeightInd> SaveUnPlanWeightInd(UnPlanWeightInd request)
 {
     if (request.Id == 0)
     {
         request.OrgId = SecurityHelper.CurrentPrincipal.OrgId;
     }
     return(base.Save <LTC_UNPLANWEIGHTIND, UnPlanWeightInd>(request, (q) => q.ID == request.Id));
 }
Exemple #2
0
        public BaseResponse <IList <UnPlanWeightInd> > QueryUnPlanWeightInd(BaseRequest <UnPlanWeightIndFilter> request)
        {
            BaseResponse <IList <UnPlanWeightInd> > response = new BaseResponse <IList <UnPlanWeightInd> >();

            var set = unitOfWork.GetRepository <LTC_UNPLANWEIGHTIND>().dbSet as IQueryable <LTC_UNPLANWEIGHTIND>;

            if (request != null && !string.IsNullOrEmpty(request.Data.OrgId))
            {
                set = set.Where(o => o.ORGID == request.Data.OrgId);
            }
            if (request != null)
            {
                set = set.Where(o => o.REGNO == request.Data.RegNo && o.FEENO == request.Data.FeeNo);
            }
            if (request.Data.ThisRecDate1 != null)
            {
                set = set.Where(o => o.THISRECDATE >= request.Data.ThisRecDate1);
            }
            if (request.Data.ThisRecDate2 != null)
            {
                set = set.Where(o => o.THISRECDATE <= request.Data.ThisRecDate2);
            }
            var q = from n in set
                    join e in unitOfWork.GetRepository <LTC_EMPFILE>().dbSet on n.RECORDBY equals e.EMPNO into res
                    from re in res.DefaultIfEmpty()
                    select new
            {
                UnPlanWeightInd = n,
                EmpName         = re.EMPNAME
            };

            q = q.OrderByDescending(m => m.UnPlanWeightInd.THISRECDATE);
            response.RecordsCount = q.Count();
            Action <IList> mapperResponse = (IList list) =>
            {
                response.Data = new List <UnPlanWeightInd>();
                foreach (dynamic item in list)
                {
                    UnPlanWeightInd newItem = Mapper.DynamicMap <UnPlanWeightInd>(item.UnPlanWeightInd);
                    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);
        }
Exemple #3
0
        public BaseResponse <List <UnPlanWeightInd> > SaveList(List <UnPlanWeightInd> request)
        {
            var list = Mapper.DynamicMap <List <UnPlanWeightInd> >(request);
            List <UnPlanWeightInd> saveList = new List <UnPlanWeightInd>();
            UnPlanWeightInd        temp     = null;

            Mapper.CreateMap <UnPlanWeightInd, LTC_UNPLANWEIGHTIND>();
            foreach (var item in request)
            {
                temp             = new UnPlanWeightInd();
                temp.OrgId       = SecurityHelper.CurrentPrincipal.OrgId;
                temp.ThisWeight  = item.ThisWeight;
                temp.ThisHeight  = item.ThisHeight;
                temp.Waist       = item.Waist;
                temp.FeeNo       = item.FeeNo;
                temp.KneeLen     = item.KneeLen;
                temp.RecordBy    = item.RecordBy;
                temp.RegNo       = item.RegNo;
                temp.ThisRecDate = item.ThisRecDate;
                temp.UnPlanFlag  = item.UnPlanFlag;
                temp.Hipline     = item.Hipline;
                temp.BMI         = item.BMI;
                temp.BMIResults  = item.BMIResults;
                var model = Mapper.Map <LTC_UNPLANWEIGHTIND>(temp);
                if (model.ID == 0)
                {
                    unitOfWork.GetRepository <LTC_UNPLANWEIGHTIND>().Insert(model);
                }
                else
                {
                    unitOfWork.GetRepository <LTC_UNPLANWEIGHTIND>().Update(model);
                }
            }
            unitOfWork.Save();
            BaseResponse <List <UnPlanWeightInd> > response = new BaseResponse <List <UnPlanWeightInd> >();

            return(response);
        }
Exemple #4
0
        public IHttpActionResult Post(UnPlanWeightInd baseRequest)
        {
            var response = service.SaveUnPlanWeightInd(baseRequest);

            return(Ok(response));
        }