Ejemplo n.º 1
0
        public ActionResult AddPost(PostViewModel postView)
        {
            if (!ModelState.IsValid) return View(postView);

            var post = Mapper.Map<Post>(postView);
            posts.Insert(post);

            return RedirectToRoute("ViewFeed", new { userName = post.GetUserName(), feedName = post.GetFeedName()});
        }
Ejemplo n.º 2
0
 public ActionResult EditPost(PostViewModel postViewModel)
 {
     if (!ModelState.IsValid) return View(postViewModel);
     var post = posts.Get(postViewModel.UserName, postViewModel.FeedName, postViewModel.Title);
     if (post == null)
         return RedirectToRoute("ViewFeed", new { userName = postViewModel.UserName, feedName = postViewModel.FeedName });
     Mapper.Map(postViewModel, post);
     posts.Update(post);
     return RedirectToRoute("ViewFeed", new { userName = postViewModel.UserName, feedName = postViewModel.FeedName });
 }
Ejemplo n.º 3
0
 public ActionResult EditPost(PostViewModel postViewModel)
 {
     if (!ModelState.IsValid) return View(postViewModel);
     var account = AzureTableExtensions.GetStorageAccount();
     var client = account.CreateCloudTableClient();
     var postsTable = client.GetTableReference<Post>();
     var post = postsTable.Retrieve<Post>(Post.CreateKey(postViewModel.UserName, postViewModel.FeedName), HttpUtility.UrlEncode(postViewModel.Title));
     if (post == null)
         return RedirectToRoute("ViewFeed", new { userName = postViewModel.UserName, feedName = postViewModel.FeedName });
     Mapper.Map(postViewModel, post);
     postsTable.Merge(post);
     return RedirectToRoute("ViewFeed", new { userName = postViewModel.UserName, feedName = postViewModel.FeedName });
 }
Ejemplo n.º 4
0
        public ActionResult AddPost(PostViewModel postView)
        {
            if (!ModelState.IsValid)
                return View(postView);
            var post = Mapper.Map<Post>(postView);

            var account = AzureTableExtensions.GetStorageAccount();
            var client = account.CreateCloudTableClient();
            var table = client.GetTableReference("Post");
            table.Insert(post);

            return RedirectToRoute("ViewFeed", new { userName = post.GetUserName(), feedName = post.GetFeedName()});
        }