示例#1
0
 public ActionResult AddOrModifyArticle(ReleaseArticleDto model)
 {
     if (!AppUser.Roles.Contains("Editor"))
     {
         return(View("Error"));
     }
     if (model.Id == null || model.Id.Equals(""))
     {
         model.Id = Guid.NewGuid().ToString();
     }
     if (ModelState.IsValid)
     {
         var article = BusinessConfig.MyArticleService.FindOneById(new Guid(model.Id));
         //发布新article时生成广播feed
         if (article == null)
         {
             article = new Article()
             {
                 AuthorId = AppUser.Id,
                 Title    = model.ArticleTitle,
                 Body     = model.ArticleBody
             };
             //是否发送广播feed
             if (model.IsReleaseBroadcastFeed)
             {
                 var feed = new Message()
                 {
                     MessageType     = "Feed.Article",
                     IsBroadcast     = true,
                     Title           = "城迹新闻",
                     Text            = model.ArticleTitle,
                     Pictures        = new List <string>(),
                     DestinationLink = "/Editor/Article/" + article.Id.ToString(),
                     NewBlank        = true,
                     ReceiverId      = Guid.Empty,
                     MessageFrom     = AppUser.Id.ToString()
                 };
                 MyService.FeedService.SendMessage(feed);
             }
         }
         else
         {
             article.Title = model.ArticleTitle;
             article.Body  = model.ArticleBody;
         }
         BusinessConfig.MyArticleService.SaveOne(article);
         return(RedirectToAction("Article", new { id = article.Id.ToString() }));
     }
     return(View("ReleaseArticle", model));
 }
示例#2
0
        public ActionResult GetEditArticle(string id = "")
        {
            if (id.Equals(""))
            {
                return(View("Error"));
            }
            var article = BusinessConfig.MyArticleService.FindOneById(new Guid(id));

            if (article == null)
            {
                return(View("Error"));
            }
            var model = new ReleaseArticleDto()
            {
                Id           = new Guid(id).ToString(),
                ArticleTitle = article.Title,
                ArticleBody  = article.Body
            };

            return(View("ReleaseArticle", model));
        }
示例#3
0
        public ActionResult ReleaseArticle()
        {
            var NewArticle = new ReleaseArticleDto();

            return(View(NewArticle));
        }