// GET: MemberArea/Blog/ConnectTo/5 public ActionResult ConnectTo(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int blogId = id.Value; int userId = Convert.ToInt32(User.Identity.GetUserId()); UserBlogConnection userBlogConnection = _uow.GetRepository <IUserBlogConnectionRepository>() .GetUserAndBlogConnection(userId, blogId); if (userBlogConnection == null) // TODO:: handle count > 1? { UserBlogConnection connection = new UserBlogConnection() { UserId = userId, BlogId = blogId, }; _uow.GetRepository <IUserBlogConnectionRepository>().Add(connection); _uow.Commit(); this.FlashSuccess("You successfully favorited a blog-"); } return(RedirectToAction("Details", "Blogs", new { area = "MemberArea", id = id })); }
// GET: MemberArea/Blog/ConnectTo/5 public IHttpActionResult ConnectTo(int blogId) { int userId = Convert.ToInt32(User.Identity.GetUserId()); UserBlogConnection userBlogConnection = _uow.GetRepository <IUserBlogConnectionRepository>() .GetUserAndBlogConnection(userId, blogId); if (userBlogConnection == null) { UserBlogConnection connection = new UserBlogConnection { UserId = userId, BlogId = blogId }; _uow.GetRepository <IUserBlogConnectionRepository>().Add(connection); _uow.Commit(); return(Ok(connection)); } return(NotFound()); }