public BaseResponse <IList <REGQUESTION> > GetEvaluationHis(NursingFilter request) { var response = new BaseResponse <IList <REGQUESTION> >(); var q = from n in unitOfWork.GetRepository <LTC_REGQUESTION>().dbSet.Where(m => m.FEENO == request.FeeNo.Value && m.QUESTIONID == request.QuestionId) join e in unitOfWork.GetRepository <LTC_EMPFILE>().dbSet on n.EVALUATEBY equals e.EMPNO into res from re in res.DefaultIfEmpty() orderby n.EVALDATE descending select new { OutValue = n, EmpName = re.EMPNAME }; Action <IList> mapperResponse = (IList list) => { response.Data = new List <REGQUESTION>(); foreach (dynamic item in list) { REGQUESTION newItem = Mapper.DynamicMap <REGQUESTION>(item.OutValue); newItem.EVALUATEBY = item.EmpName; response.Data.Add(newItem); } }; var result = q.ToList(); mapperResponse(result); return(response); }
public BaseResponse <REGQUESTION> GetLatestRegQuetion(long feeNo, int quetionId) { var response = new BaseResponse <REGQUESTION>(); REGQUESTION RegQuestion = new REGQUESTION(); Mapper.CreateMap <LTC_REGQUESTION, REGQUESTION>(); LTC_REGQUESTION regQuestion = unitOfWork.GetRepository <LTC_REGQUESTION>().dbSet.Where(m => m.FEENO == feeNo && m.QUESTIONID == quetionId).OrderByDescending(x => x.EVALDATE).FirstOrDefault(); Mapper.Map(regQuestion, RegQuestion); response.Data = RegQuestion; return(response); }
public BaseResponse <REGQUESTION> GetREGQuetion(long recordId) { var response = new BaseResponse <REGQUESTION>(); REGQUESTION RegQuestion = new REGQUESTION(); Mapper.CreateMap <LTC_REGQUESTION, REGQUESTION>(); LTC_REGQUESTION regQuestion = unitOfWork.GetRepository <LTC_REGQUESTION>().dbSet.Where(m => m.RECORDID == recordId).FirstOrDefault(); Mapper.Map(regQuestion, RegQuestion); response.Data = RegQuestion; return(response); }
public IHttpActionResult Post(REGQUESTION baseRequest) { try { var response = nursingSvc.SaveQuetion(baseRequest); return(Ok(response)); } catch (Exception ex) { LogHelper.WriteError(ex.ToString()); return(Ok(new BaseResponse <string> { ResultCode = (int)EnumResponseStatus.ExceptionHappened, ResultMessage = "操作异常" })); } }
public BaseResponse SaveQuetion(REGQUESTION request) { var response = new BaseResponse(); Mapper.CreateMap <REGQUESTION, LTC_REGQUESTION>(); var model = unitOfWork.GetRepository <LTC_REGQUESTION>().dbSet.Where(m => m.RECORDID == request.RECORDID).FirstOrDefault(); if (model == null) { model = Mapper.Map <LTC_REGQUESTION>(request); //SecurityHelper.CurrentPrincipal.EmpNo; model.ORGID = SecurityHelper.CurrentPrincipal.OrgId; if (!model.EVALDATE.HasValue) { model.EVALDATE = DateTime.Now; } unitOfWork.GetRepository <LTC_REGQUESTION>().Insert(model); unitOfWork.Save(); Mapper.CreateMap <REGQUESTIONDATA, LTC_REGQUESTIONDATA>(); List <LTC_REGQUESTIONDATA> questionData = Mapper.Map <List <LTC_REGQUESTIONDATA> >(request.QuestionDataList); if (questionData != null) { questionData.ForEach(p => p.RECORDID = model.RECORDID); unitOfWork.GetRepository <LTC_REGQUESTIONDATA>().InsertRange(questionData); } } else { Mapper.Map(request, model); unitOfWork.GetRepository <LTC_REGQUESTION>().Update(model); List <LTC_REGQUESTIONDATA> regQueData = unitOfWork.GetRepository <LTC_REGQUESTIONDATA>().dbSet.Where(m => m.RECORDID == request.RECORDID).ToList(); regQueData.ForEach(p => unitOfWork.GetRepository <LTC_REGQUESTIONDATA>().Delete(p)); Mapper.CreateMap <REGQUESTIONDATA, LTC_REGQUESTIONDATA>(); List <LTC_REGQUESTIONDATA> questionData = Mapper.Map <List <LTC_REGQUESTIONDATA> >(request.QuestionDataList); questionData.ForEach(p => p.RECORDID = model.RECORDID); unitOfWork.GetRepository <LTC_REGQUESTIONDATA>().InsertRange(questionData); } unitOfWork.Save(); return(response); }
public BaseResponse <IList <REGQUESTION> > GetEvaluationHisOver(BaseRequest <NursingFilter> request) { var response = new BaseResponse <IList <REGQUESTION> >(); var q = from n in unitOfWork.GetRepository <LTC_REGQUESTION>().dbSet.Where(m => m.FEENO == request.Data.FeeNo.Value && m.QUESTIONID == request.Data.QuestionId) join e in unitOfWork.GetRepository <LTC_EMPFILE>().dbSet on n.EVALUATEBY equals e.EMPNO into res from re in res.DefaultIfEmpty() orderby n.EVALDATE descending select new { OutValue = n, EmpName = re.EMPNAME }; Action <IList> mapperResponse = (IList list) => { response.Data = new List <REGQUESTION>(); foreach (dynamic item in list) { REGQUESTION newItem = Mapper.DynamicMap <REGQUESTION>(item.OutValue); newItem.EVALUATEBY = item.EmpName; response.Data.Add(newItem); } }; response.RecordsCount = q.Count(); 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); }