예제 #1
0
        public ActionResult GetClassify(long id)
        {
            var result     = new JsonModel();
            var articleClz = ArticleClassifyRepository.Get(id);

            if (articleClz == null)
            {
                result.msg = "找不到记录!";
                return(Json(result));
            }
            articleClz.PicUrl = AttachmentSvc.GetPicUrl(articleClz.PicAttaId, 100, 100);
            result.data       = articleClz;
            result.code       = JsonModelCode.Succ;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Save(ArticleClassifyModel model)
        {
            var             result = new JsonModel();
            ArticleClassify parent = null;

            if (model.PId != 0)
            {
                parent = ArticleClassifyRepository.Get(model.PId);
                if (parent == null)
                {
                    result.msg = "找不到id为" + model.PId + "的主分类!";
                    return(Json(result));
                }
            }

            var             operationType   = OperationType.Insert;
            ArticleClassify articleClassify = null;

            if (model.Id > 0)
            {
                articleClassify = ArticleClassifyRepository.Get(model.Id);
                if (articleClassify == null)
                {
                    result.msg = "记录不存在了";
                    return(Json(result));
                }
                operationType = OperationType.Update;
            }
            else
            {
                articleClassify = new ArticleClassify();
            }
            Mapper.Map(model, articleClassify);
            ArticleClassifyRepository.Save(articleClassify, parent);
            LogRepository.Insert(TableSource.ArticleClassify, operationType, articleClassify.Id);
            result.msg  = "保存成功!";
            result.code = JsonModelCode.Succ;
            result.data = articleClassify;
            return(Json(result));
        }
예제 #3
0
        public ActionResult Edit(long id, string reUrl)
        {
            ViewBag.ReUrl = reUrl ?? Url.Action("Index");
            var model = new ArticleModel()
            {
                ArticleDateTime = DateTime.Now,
                ExecutiveEditor = User.UserModel.UserName,
                CommonStatus    = CommonStatus.Enabled,
                ArticleTarget   = ArticleTarget.ThisPage,
                PartialViewCode = ArticleDetailType.Article
            };

            if (id == 0)
            {
                return(View(model));
            }
            var article = ArticleRepository.Get(id);

            if (article == null)
            {
                ShowErrorMsg();
                return(Redirect(ViewBag.ReUrl));
            }
            Mapper.Map(article, model);
            var clz = ArticleClassifyRepository.Get(model.ClassifyId);

            if (clz != null)
            {
                model.ClassifyName = clz.Name;
            }
            if (!string.IsNullOrEmpty(model.FocusMap))
            {
                model.FocusMapList = JsonConvert.DeserializeObject <List <ArticleFocusMapModel> >(model.FocusMap);
            }
            return(View(model));
        }