示例#1
0
 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));
       }
 }
示例#2
0
 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"));
     }
 }
示例#3
0
 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"));
     }
 }
示例#4
0
 public ActionResult New(PostNewModel post)
 {
     var userName = _userTasks.GetCurrentUserName();
       return View(post ?? new PostNewModel{AuthorUserName = userName});
 }