/// <summary>
        /// 编辑分类
        /// </summary>
        /// <returns></returns>
        public IActionResult LearningTypeEdit(LearningTypeModel model)
        {
            LearningTypeModel vmodel = new LearningTypeModel();
            string            id     = GetParameterViewBag("id");

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

            View(vmodel);


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

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

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

            return(View());
        }
Exemple #2
0
        public LearningTypeModel ConverToTypeModel(LearningType model)
        {
            LearningTypeModel vmodel = new LearningTypeModel();

            vmodel.Name       = model.Name;
            vmodel.Desc       = model.Desc;
            vmodel.ParentId   = model.ParentId;
            vmodel.ParentName = GetTypeAttr(model.ParentId);
            vmodel.CreateDate = model.CreateDate;
            vmodel.Id         = model.Id;
            vmodel.ImgUrl     = model.ImgUrl;
            vmodel.LinkUrl    = model.LinkUrl;

            return(vmodel);
        }
Exemple #3
0
        public ServiceResult AddType(LearningTypeModel model)
        {
            ServiceResult result = new ServiceResult();

            LearningType info = new LearningType();

            info.CompanyId    = model.CompanyId;
            info.CreateDate   = DateTime.Now;
            info.CreateUserId = model.UserId;
            info.Desc         = model.Desc;
            info.ImgUrl       = model.ImgUrl;
            info.LastDate     = DateTime.Now;
            info.LastUserId   = model.UserId;
            info.Name         = model.Name;
            info.ParentId     = model.ParentId;
            info.LinkUrl      = model.LinkUrl;

            var id = _learningType.Insert(info);

            return(result);
        }
Exemple #4
0
        public ServiceResult UpdateType(LearningTypeModel model)
        {
            ServiceResult result = new ServiceResult();

            var info = _learningType.Get(model.Id);

            if (info != null)
            {
                info.LastDate   = DateTime.Now;
                info.LastUserId = model.UserId;
                info.Name       = model.Name;
                info.Desc       = model.Desc;
                info.ParentId   = model.ParentId;
                info.ImgUrl     = model.ImgUrl;
                info.CompanyId  = model.CompanyId;
                info.LinkUrl    = model.LinkUrl;

                _learningType.Update(info);
            }

            return(result);
        }