Exemplo n.º 1
0
        public IActionResult ResendForApproval(MyRejectedArticleViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                this.articlesService.EditArticleAndResendForApproval(model);
                return(RedirectToAction("ArticlesMenu"));
            }

            var reloadModel = this.menuService.GetMenuItems(this.GetType(), typeof(HttpGetAttribute), typeof(AuthorizeAttribute), AreaName, "OpenMyRejectedArticle", model);

            return(View("ArticlesMenu", reloadModel));
        }
Exemplo n.º 2
0
        public Article EditArticleAndResendForApproval(MyRejectedArticleViewModel model)
        {
            var article = this.context.Articles.FirstOrDefault(a => a.Id == model.Id);

            if (article == null)
            {
                return(null);
            }

            article.Title             = model.Title;
            article.Content           = model.Content;
            article.IsRejected        = false;
            article.IsSentForApproval = true;

            if (model.NewImage != null)
            {
                string newImageLocation = this.imagesService.RecreateImage(model.NewImage, this.GetType().Name.Replace("Service", string.Empty), model.ImageLocation, model.Id);
                article.ImageLocation = newImageLocation;
            }

            context.SaveChanges();
            return(article);
        }