public void FollowCategory(CategoryFollower categoryFollower) { string query = @"INSERT INTO CategoryFollowers (CategoryID, FollowerID) values(@CategoryID, @FollowerID)"; _connection.Execute(query, new { categoryFollower.CategoryID, categoryFollower.FollowerID }); }
public void UnfollowCategory(CategoryFollower categoryFollower) { string query = @"DELETE FROM CategoryFollowers WHERE CategoryID = @CategoryID AND FollowerID = @FollowerID"; _connection.Execute(query, new { categoryFollower.CategoryID, categoryFollower.FollowerID }); }
protected void btnUnfollow_Click(object sender, EventArgs e) { var currentUser = _authenticationService.GetAuthenticatedUser(); int categoryID = Convert.ToInt32(Page.RouteData.Values["id"]); if (currentUser == null) { redirectToLogin(Request.RawUrl); } var categoryFollower = new CategoryFollower(categoryID, currentUser.Id); _categoryService.UnfollowCategory(categoryFollower); btnUnfollow.Style.Add("display", "none"); btnFollow.Style.Add("display", "inline-block"); loadFollowers(categoryID, currentUser); }