public ActionResult Create(PostNewModel post) { try { post.AuthorUserName = _userTasks.GetCurrentUserName(); Post newPost = _postTasks.SaveNewPost(_postCreateMapper.MapFrom(post)); return this.RedirectToAction(x => x.Show(newPost.Slug)); } catch { return this.RedirectToAction(x => x.New(post)); } }
public ActionResult Create(PostNewModel e) { try { var post = new PostEntity() { Text = e.Text }; postService.Create(post); return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Create(PostNewModel e) { try { var post = new Posts() { Text = e.Text, UserId = userService.getUserByName(User.Identity.Name).UserId }; postService.Create(post); return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult New(PostNewModel post) { var userName = _userTasks.GetCurrentUserName(); return View(post ?? new PostNewModel{AuthorUserName = userName}); }