Ejemplo n.º 1
0
        protected void InsertOrUpdateTemp(PollingResultTempView objModal, string Id)
        {
            if (string.IsNullOrEmpty(Id) || Id == "0")
            {
                objModal.UserId = ViewBag.lillyid;

                _objResultTempService.InsertView(objModal);
            }
            else
            {
                _objResultTempService.UpdateView(objModal);
            }
        }
        public ActionResult InputDataTemp(PollingResultTempView objModal, string Id)
        {
            objModal.UserId = ViewBag.LillyId;
            int userCount = _objResultTempService.GetTempCountByLillyID(objModal.PollingId, ViewBag.LillyId);

            //已有数据,需要删除
            if (userCount > 0)
            {
                _objResultTempService.Delete(objModal.PollingId, ViewBag.LillyId);
            }
            InsertOrUpdateTemp(objModal, Id);
            //_objService.InsertResultTemp(objModal);
            return(Json(new { Status = 200, Data = objModal.PollingId }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        private int AddOrUpdate(PollingResultTempView objModalSrc, bool bolAdd)
        {
            PollingResultTempView objView = objModalSrc;

            if (objView == null)
            {
                return(-1);
            }
            int iRet;
            var pollings = new List <PollingResultTempEntity>();
            PollingResultTempEntity polling = new PollingResultTempEntity();

            objView.AnswerResults.ToList().ForEach(x =>
            {
                polling = new PollingResultTempEntity
                {
                    PollingId    = objModalSrc.PollingId,
                    QuestionId   = x.QuestionId,
                    QuestionName = x.QuestionName,
                    Answer       = x.Answer,
                    AnswerText   = x.AnswerText,
                    UserId       = objModalSrc.UserId
                };
                pollings.Add(polling);

                if (!bolAdd)
                {
                    // 应为没有批量更新
                    iRet = Repository.Update(polling);
                }
            });

            if (bolAdd)
            {
                iRet = Repository.Insert(pollings.AsEnumerable());
            }

            return(1);
        }
Ejemplo n.º 4
0
 public new int UpdateView(PollingResultTempView objModalSrc)
 {
     return(AddOrUpdate(objModalSrc, false));
 }
Ejemplo n.º 5
0
 public new int InsertView(PollingResultTempView objModalSrc)
 {
     return(AddOrUpdate(objModalSrc, true));
 }