Beispiel #1
0
        public ServiceResult UpdateInfo(LearningInfoModel model)
        {
            ServiceResult result = new ServiceResult();

            LearningInfo info = SingleInfo(model.Id);

            info.Desc       = model.Desc;
            info.LastDate   = DateTime.Now;
            info.LastUserId = model.UserId;
            info.Title      = model.Title;
            info.Content    = model.Content;
            info.ParentId   = model.ParentId;
            info.Labs       = model.Labs;
            info.Id         = model.Id;
            info.TitleImgs  = model.TitleImgs;

            _learningInfo.Update(info);


            result.Code    = 1;
            result.Message = "更新成功";
            result.State   = ServiceState.Success;

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 编辑内容
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IActionResult LearningInfoEdit(LearningInfoModel model)
        {
            LearningInfoModel vmodel = new LearningInfoModel();
            string            id     = GetParameterViewBag("id");

            if (!string.IsNullOrEmpty(id))
            {
                var info = _learningService.SingleInfo(id);
                vmodel = _learningService.ConverToInfoModel(info);
            }

            View(vmodel);


            if (Post)
            {
                model.SetBase(HttpContext);

                if (string.IsNullOrEmpty(id))
                {
                    var result = _learningService.AddInfo(model);
                }
                else
                {
                    var result = _learningService.UpdateInfo(model);
                }

                return(RedirectToAction("LearningInfoList", "Learning"));
            }

            return(View());
        }
Beispiel #3
0
        public LearningInfoModel ConverToInfoModel(LearningInfo model)
        {
            LearningInfoModel vmodel = new LearningInfoModel();

            vmodel.Id         = model.Id;
            vmodel.Labs       = model.Labs;
            vmodel.Title      = model.Title;
            vmodel.TitleImgs  = model.TitleImgs;
            vmodel.ParentId   = model.ParentId;
            vmodel.UserId     = model.CreateUserId;
            vmodel.Desc       = model.Desc;
            vmodel.Content    = model.Content;
            vmodel.CompanyId  = model.CompanyId;
            vmodel.CreateDate = model.CreateDate;
            return(vmodel);
        }
Beispiel #4
0
        public ServiceResult AddInfo(LearningInfoModel model)
        {
            ServiceResult result = new ServiceResult();
            LearningInfo  info   = new LearningInfo();

            info.CreateDate   = DateTime.Now;
            info.LastDate     = DateTime.Now;
            info.Desc         = model.Desc;
            info.Content      = model.Content;
            info.LastUserId   = model.UserId;
            info.Labs         = model.Labs;
            info.CreateUserId = model.UserId;
            info.CompanyId    = model.CompanyId;
            info.Title        = model.Title;
            info.TitleImgs    = model.TitleImgs;

            _learningInfo.Insert(info);

            return(result);
        }