public async Task <IActionResult> UpdateArticleAsync(int id) { Article UpdateArticle = await ArticleOperations.Get(id); ArticleUpdateModel updateArticle = new ArticleUpdateModel(UpdateArticle); return(View(updateArticle)); }
public IActionResult ArticleDelete(Article article) { if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Accounts")); } APIHelper.InitializeClient(); ArticleOperations.Delete(article.ArticleId); ModelState.Clear(); return(RedirectToAction("Index")); }
public async Task <IActionResult> IndexAsync(string tag) { IndexViewModel viewModel = new IndexViewModel(); APIHelper.InitializeClient(); List <ArticleCard> cardList = await ArticleOperations.GetAllCards(); cardList.Reverse(); viewModel.RecentArticles = cardList; viewModel.FilteredArticles = cardList; if (!String.IsNullOrEmpty(tag)) { viewModel.FilteredArticles = cardList.Where(article => article.Tag.Equals(tag)).ToList(); } return(View(viewModel)); }
public async Task <IActionResult> ArticleUpload(ArticleUploadViewModel model, string correctAnswer1, string correctAnswer2) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Accounts")); } //if (ModelState.IsValid != true) //{ // return View(model); //} APIHelper.InitializeClient(); Question question1 = model.Questions[0]; Question question2 = model.Questions[1]; if (correctAnswer1 == "Answer1") { question1.CorrectAnswer = question1.Answer1; } else if (correctAnswer1 == "Answer2") { question1.CorrectAnswer = question1.Answer2; } if (correctAnswer2 == "Answer1") { question2.CorrectAnswer = question2.Answer1; } else if (correctAnswer2 == "Answer2") { question2.CorrectAnswer = question2.Answer2; } await ArticleOperations.Create(model); question1.ArticleId = await ArticleOperations.GetArticleId(model.Author); question2.ArticleId = await ArticleOperations.GetArticleId(model.Author); QuestionOperations.Create(question1); QuestionOperations.Create(question2); ModelState.Clear(); return(RedirectToAction("Index")); }
public async Task <IActionResult> ArticleView(int id) { Article article = await ArticleOperations.Get(id); List <Question> questions = await QuestionOperations.Get(id); ArticleViewViewModel articleViewViewModel = new ArticleViewViewModel { ArticleId = article.ArticleId, Title = article.Title, Author = article.Author, Summary = article.Summary, Tag = article.Tag, HeaderImage = article.HeaderImage, Content = article.Content, Questions = questions }; if (article != null) { return(View(articleViewViewModel)); } return(RedirectToAction("Index")); }
public IEnumerable <Article> GetArticles(bool includeUnlisted = false) { return(ArticleOperations.GetArticles(includeUnlisted)); }
public Article GetArticle(int articleId) { return(ArticleOperations.GetArticle(articleId)); }
public Article CreateArticle(Article article) { return(ArticleOperations.CreateArticle(article)); }
public Article AddArticle(Article article) { return(ArticleOperations.AddArticle(article)); }
public void UpdateArticle(Article article) { ArticleOperations.UpdateArticle(article); }
public void DeleteArticle(int articleId) { ArticleOperations.DeleteArticle(articleId); }
public async Task <IActionResult> DeletePageAsync(int id) { Article article = await ArticleOperations.Get(id); return(View(article)); }
public IActionResult Update(ArticleUpdateModel article) { ArticleOperations.Update(article); return(RedirectToAction("Index")); }