public ActionResult Create(Post post) { try { if (ModelState.IsValid) { var listOfTags = SeparateTags(post.Tags); post.InternalTags = listOfTags; post.FriendlyUrl = SlugConverter.TitleToSlug(post.Title); // TODO check if this url is uniqe DataSession.Store(post); DataSession.SaveChanges(); TempData["success"] = "Inlägget sparat"; UpdateModel("Index"); return(RedirectToAction("Index")); } } catch (Exception) { TempData["error"] = "MIsslyckades med att publicera inlägget"; } return(View(post)); }
public ActionResult Edit(Blog blog) { if (ModelState.IsValid) { DataSession.Store(blog, "blogs/" + blog.Id); DataSession.SaveChanges(); return(RedirectToAction("Index")); } return(View(blog)); }
public ActionResult Create(Blog blog) { if (ModelState.IsValid) { blog.CreatedAt = DateTime.UtcNow; //if (blog.Banner != null) // { // var photo = new byte[blog.Banner.ContentLength]; // blog.Banner.InputStream.Read(photo, 0, blog.Banner.ContentLength); // } DataSession.Store(blog); DataSession.SaveChanges(); return(RedirectToAction("Index")); } return(View(blog)); }
public ActionResult Create(Comment comment) { try { if (ModelState.IsValid) { DataSession.Store(comment); DataSession.SaveChanges(); TempData["success"] = "Kommentaren skickad för granskning"; return(RedirectToAction("Index")); } } catch (Exception) { TempData["error"] = "MIsslyckades med att publicera inlägget"; } return(View("Index")); }
public ActionResult Edit(Post post) { if (ModelState.IsValid) { try { var listOfTags = SeparateTags(post.Tags); post.InternalTags = listOfTags; DataSession.Store(post, "posts/" + post.Id); DataSession.SaveChanges(); TempData["success"] = string.Format("Uppdaterade posten {0}", post.Title); UpdateModel("Index"); return(RedirectToAction("Index")); } catch (Exception) { TempData["error"] = string.Format("Misslyckades att uppdatera {0}", post.Title); } } return(View(post)); }