Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        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."));
            }
        }