public ActionResult ReviewArticle(int? articleId) { var reviewArticleModel = new ReviewArticleModel(); using (var itx = _Session.BeginTransaction()) { var articleUnderReview = _Session.QueryOver<Article>() .Where(x => x.Id == articleId) .SingleOrDefault(); reviewArticleModel.ArticleId = articleUnderReview.Id; reviewArticleModel.Created = articleUnderReview.Creation; reviewArticleModel.AuthorFirstName = articleUnderReview.User.FirstName; reviewArticleModel.AuthorLastName = articleUnderReview.User.LastName; reviewArticleModel.Title = articleUnderReview.Title; reviewArticleModel.Case = articleUnderReview.Case; itx.Commit(); } return View(reviewArticleModel); }
public ActionResult ReviewArticle(ReviewArticleModel articleReview) { if (ModelState.IsValid == false || articleReview == null) { return View(); } using (var itx = _Session.BeginTransaction()) { var article = _Session.QueryOver<Article>().Where(x => x.Id == articleReview.ArticleId).SingleOrDefault(); if (article == null) { ModelState.AddModelError("ArticleId", "An error occured."); return View(); } var review = new Review(); review.Approved = articleReview.Accepted; var id = Int32.Parse(User.Identity.Name.Split('|')[1]); review.Reviewer = _Session.QueryOver<User>() .Where(x => x.Id == id) .SingleOrDefault(); review.Comment = articleReview.ReviewComment; review.Created = DateTime.Now; review.Article = _Session.QueryOver<Article>() .Where(x=>x.Id == articleReview.ArticleId) .SingleOrDefault(); review.Article.Reviews.Add(review); var reviewCountConfig = _Session.QueryOver<Config>().SingleOrDefault().RevCount; if (review.Article.Reviews.Count >= reviewCountConfig) { review.Article.Published = DateTime.Now; } _Session.Update(review.Article); _Session.Save(review); itx.Commit(); } return RedirectToAction("ThankYouSubmission"); }