public async Task<ActionResult> AddNews(News fc) { ParseObject newsObj = new ParseObject("News"); newsObj["title"] = fc.title; newsObj["content"] = fc.content; await newsObj.SaveAsync(); return RedirectToAction("ShowNews"); }
public async Task<ActionResult> EditNews(string id, News fc) { ParseQuery<ParseObject> query = ParseObject.GetQuery("News"); ParseObject news = await query.GetAsync(id); news["title"] = fc.title; news["content"] = fc.content; await news.SaveAsync(); return RedirectToAction("ShowNews"); }
public async Task<ActionResult> EditNews(string id) { ParseQuery<ParseObject> query = ParseObject.GetQuery("News"); ParseObject news = await query.GetAsync(id); News n = new News(); n.NewsId = news.ObjectId; n.title = news.Get<string>("title"); n.content = news.Get<string>("content"); return View(n); }
public async Task<ActionResult> ShowNews() { ParseQuery<ParseObject> query = ParseObject.GetQuery("News"); IEnumerable<ParseObject> _news = await query.FindAsync(); List<News> _newsList = new List<News>(); foreach (ParseObject n in _news) { News news = new News(); news.NewsId = n.ObjectId; news.title = n.Get<string>("title"); news.content = n.Get<string>("content"); _newsList.Add(news); } return View(_newsList); }