public ActionResult Create(PermissionArea Area, ApType ApType, PostEdit PostEdit) { if (!ModelState.IsValid) { ViewData["Post"] = PostEdit; ViewData["Salt"] = "PostCreate"; return View("Form" + ApType.ToProper(), Area); } ////////////////////////// // Everything passed. Create new post ////////////////////////// var post = Mapper.Map<PostEdit, Post>(PostEdit); middleManagement.Post.Add(post); ////////////////////////// // Send user to new post ////////////////////////// return RedirectToAction("View", "Blog", new { postid = post.ID, title = post.Title.ToUrlFriendly() }); }
public ActionResult Create(PermissionArea Area, ApType ApType) { var postEdit = GetType(ApType); ViewData["Post"] = postEdit; ViewData["Salt"] = "PostCreate"; return View("Form" + ApType.ToProper(), Area); }
public ActionResult Edit(PermissionArea Area, PostEdit PostEdit, ApType ApType) { if (!ModelState.IsValid) { ViewData["Post"] = PostEdit; ViewData["Salt"] = "PostEdit"; return View("Form" + ApType.ToProper(), Area); } var postToSave = Mapper.Map<PostEdit, Post>(PostEdit); middleManagement.Post.Save(postToSave); return RedirectToAction("View", "Blog", new { postid = postToSave.ID, title = postToSave.Title.ToUrlFriendly() }); }
private PostEdit GetType(ApType Type) { PostEdit postEdit; switch (Type) { case ApType.blog: postEdit = new PostEdit { Type = Type.ToProper(), Format = Format.PlainText, Published = true, Promote = true }; break; default: throw new ArgumentOutOfRangeException(""); } return postEdit; }
public ActionResult Edit(PermissionArea Area, PermissionPost Post, ApType ApType) { PostEdit postEdit; switch (ApType) { case ApType.blog: postEdit = Mapper.Map<Post, PostEdit>(Post.Entity); break; default: throw new ArgumentOutOfRangeException("ApType"); } ViewData["Post"] = postEdit; ViewData["Salt"] = "PostEdit"; return View("Form" + ApType.ToProper(), Area); }