public ActionResult FollowTopic(FormCollection fc) { if (!AuthorizeUser()) { return(RedirectToAction("Login", "Accounts")); } try { var user_id = int.Parse(Session["user_id"].ToString()); // feed follow var selectedTopics = fc["selectedTopics"].Split(',').ToList(); FollowTopicRepository topicRepository = new FollowTopicRepository(); topicRepository.DeleteByUser(user_id); topicRepository.AddTopics(user_id, selectedTopics); return(RedirectToAction("Feed")); } catch { ViewBag.Message = "Failed to follow the selected topics"; return(View()); } }
public HttpResponseMessage DeleteTopicByUser(int user_id) { try { ftrepo.DeleteByUser(user_id); return(Request.CreateResponse(HttpStatusCode.NoContent)); } catch { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Failed to delete the following topics.")); } }