public ActionResult AddComment(string Id, int ItemId,string comment)
        {
            DataRepository helper = new DataRepository();

            string commentLeaver = "";
            if (Session["Username"] == null)
            {
                ViewData["Alert"] = "Please sign in to leave a comment";
                Item itemB = helper.getItem(ItemId);
                IList<ItemComment> commentsB = helper.getComments(ItemId);
                IList<Link> linksB = helper.getLinks(ItemId);

                DiscussionViewModel modelB = new DiscussionViewModel(ItemId, commentsB, linksB,"", "", itemB, "", "","","");
                return PartialView(modelB);
            }
            else
                commentLeaver = Session["Username"].ToString();

            helper.AddComment(commentLeaver, ItemId, comment);

            Item item = helper.getItem(ItemId);
            IList<ItemComment> comments = helper.getComments(ItemId);
            IList<Link> links = helper.getLinks(ItemId);

            DiscussionViewModel model = new DiscussionViewModel(ItemId, comments, links,"", "", item, "", "","","");

            return PartialView(model);
        }
 public ActionResult AllLinks(int ItemId)
 {
     DataRepository helper = new DataRepository();
     IList<Link> links = helper.getLinks(ItemId);
     Item item = helper.getItem(ItemId);
     DiscussionViewModel model = new DiscussionViewModel(ItemId,null, links, "", "", item, "", "", "", "");
     return PartialView(model);
 }
        public ActionResult Register(RegisterViewModel viewModel)
        {
            DataRepository helper = new DataRepository();

            List<SelectListItem> items = new List<SelectListItem>();

            items.Add(new SelectListItem
             {
            Text = "Female",
            Value = "0"
            });
            items.Add(new SelectListItem
            {
                Text = "Male",
                Value = "1"
            });
            items.Add(new SelectListItem
            {
                Text = "Prefer not to say",
                Value = "2"
            });

            viewModel.GenderOptions = items;

            List<SelectListItem> dobItems = new List<SelectListItem>();
            int j = 0;
            for (int i = (int)DateTime.Now.Year; i > Convert.ToInt32(DateTime.Now.Year) - 122; i--)
            {
                dobItems.Add(new SelectListItem
                {
                    Text = i.ToString(),
                    Value = i.ToString()
                });
                j++;
            }

            dobItems.Add(new SelectListItem
            {
                Text = "Prefer not to say",
                Value = j.ToString()
            });

            viewModel.dobYearOptions = dobItems;

            List<SelectListItem> counties = new List<SelectListItem>();

            IList<County> allCounties = helper.getCounties();

            foreach (var county in allCounties)
            {
                counties.Add(new SelectListItem { Text = county.County1, Value = county.County1 });
            }

            viewModel.countyOptions = counties;

            return View(viewModel);
        }
        public ActionResult DeleteItem(int ItemId)
        {
            DataRepository helper = new DataRepository();

            string username = Session["Username"].ToString();
            helper.DeleteItem(ItemId);
            IList<Item> mostRecentItems = helper.getItemsByUser(username);
            //initialise item view model but filter by single user logged in
            return PartialView(new ItemViewModel(null, null, null, null, null, mostRecentItems, username, "User", "", "", false, "", "", "",""));
        }
        //
        // GET: /Account/
        public ActionResult Index()
        {
            DataRepository helper = new DataRepository();

            string username = Session["Username"].ToString();

            IList<Item> mostRecentItems = helper.getItemsByUser(username);
            //initialise item view model but filter by single user logged in
            IList<FollowConnection> friends = helper.getFollowConnections(username);

            ViewData["Friends"] = friends;
            return View(new ItemViewModel(null, null, null, null, null, mostRecentItems, username, "User","" , "", false, "", "", "",""));
        }
 public ActionResult AddLink(string Id,int ItemId)
 {
     if (Session["Username"] != null)
     {
         DataRepository helper = new DataRepository();
         Item item = helper.getItem(ItemId);
         DiscussionViewModel model = new DiscussionViewModel(ItemId, null, null, "", "", item, "", "", "", "");
         return PartialView(model);
     }
     else
     {
         return PartialView("LoginAlert");
     }
 }
        public ActionResult AddLinkRequest(int itemId, string link)
        {
            //store new item, link and new comment(if not null)
            DataRepository helper = new DataRepository();

            if (!helper.linkExists(link, itemId))
                helper.AddLink(link, itemId, Session["Username"].ToString());
            else
            {
                helper.LikeLinkInstead(link, itemId);
                TempData["LinkExists"] = "That link has already been added against this recommendation. We have liked this link instead.";
            }

            Item item = helper.getItemById(itemId.ToString());

            return RedirectToAction("Discussion", new {Id = item.Username, state = "Network", itemId = itemId });
        }
        public ActionResult LoginRequest(LoginViewModel viewModel)
        {
            DataRepository helper = new DataRepository();

            if (helper.UserCanLogIn(viewModel))
            {
                viewModel.user = helper.GetUser(viewModel);
                Session["LoggedIn"] = "true";
                Session["Username"] = viewModel.user.Username.ToString();

                ViewData["ReloadPage"] = "true";

                return PartialView();
            }

            TempData["ErrorMessage"] = "Login Failed";
            return PartialView();
        }
        public ActionResult LikeLink(string LinkId)
        {
            DataRepository helper = new DataRepository();

            helper.LikeLink(Convert.ToInt32(LinkId));

            ViewData["Id"] = LinkId;

            return PartialView();
        }
Ejemplo n.º 10
0
        public ActionResult LikeComment(string Id, int ItemId)
        {
            DataRepository helper = new DataRepository();

            helper.LikeComment(Id);

            Item item = helper.getItem(ItemId);
            IList<ItemComment> comments = helper.getComments(ItemId);
            IList<Link> links = helper.getLinks(ItemId);

            DiscussionViewModel model = new DiscussionViewModel(ItemId, comments, links, "", "", item, "", "","","");

            ViewData["Id"] = Id;

            return PartialView(model);
        }
Ejemplo n.º 11
0
        public ActionResult Like(string ItemId,string Id,string state,string guid)
        {
            DataRepository helper = new DataRepository();

            ViewData["ItemId"] = ItemId;
            ViewData["Id"] = Id;
            ViewData["State"] = state;
            ViewData["Guid"] = guid;

            helper.LikeItem(ItemId);

            return PartialView();
        }
Ejemplo n.º 12
0
        public ActionResult Index(string Id, string state)
        {
            int ten = 10;
            if (state != "Global" && state != null)
            {
                DataRepository helper = new DataRepository();

                IList<Item> songs = helper.getSpecificItemsInNetwork(Id,1,ten);
                IList<Item> films = helper.getSpecificItemsInNetwork(Id,6,ten);
                IList<Item> books = helper.getSpecificItemsInNetwork(Id,3,ten);
                IList<Item> games = helper.getSpecificItemsInNetwork(Id,4,ten);
                IList<Item> apps = helper.getSpecificItemsInNetwork(Id,5,ten);
                IList<Item> mostRecentItems = helper.getMostRecentItemsInNetwork(Id,ten);
                string yob = helper.getYOB(Id);
                string stereotype = helper.getStereotype(Id);
                bool male = helper.isMale(Id);
                string recentItem = helper.getMostRecentItem(Id);
                string recentItemId = helper.getMostRecentItemId(Id);
                string location = helper.getLocation(Id);

                ViewData["songsTopLinks"] = helper.getItemTopLinks(songs);
                ViewData["songsYouTubes"] = helper.getItemYouTubes(songs);

                ViewData["filmsTopLinks"] = helper.getItemTopLinks(films);
                ViewData["filmsYouTubes"] = helper.getItemYouTubes(films);

                ViewData["booksTopLinks"] = helper.getItemTopLinks(books);
                ViewData["booksYouTubes"] = helper.getItemYouTubes(books);

                ViewData["gamesTopLinks"] = helper.getItemTopLinks(games);
                ViewData["gamesYouTubes"] = helper.getItemYouTubes(games);

                ViewData["appsTopLinks"] = helper.getItemTopLinks(apps);
                ViewData["appsYouTubes"] = helper.getItemYouTubes(apps);

                ViewData["recentTopLinks"] = helper.getItemTopLinks(mostRecentItems);
                ViewData["recentYouTubes"] = helper.getItemYouTubes(mostRecentItems);

                ViewData["Following"] = helper.getFollowingCount(Id);
                ViewData["FollowedBy"] = helper.getFollowedByCount(Id);

                return View(new ItemViewModel(songs, films, books, games, apps,mostRecentItems,Id,"User",yob,stereotype,male,recentItem,"",recentItemId,location));
            }
            else//Global State
            {
                DataRepository helper = new DataRepository();
                IList<Item> songs = helper.getSpecificItems(1,ten);
                IList<Item> films = helper.getSpecificItems(6, ten);
                IList<Item> books = helper.getSpecificItems(3, ten);
                IList<Item> games = helper.getSpecificItems(4, ten);
                IList<Item> apps = helper.getSpecificItems(5, ten);
                IList<Item> mostRecentItems = helper.getMostRecentItems(ten);

                ViewData["songsTopLinks"] = helper.getItemTopLinks(songs);
                ViewData["songsYouTubes"] = helper.getItemYouTubes(songs);

                ViewData["filmsTopLinks"] = helper.getItemTopLinks(films);
                ViewData["filmsYouTubes"] = helper.getItemYouTubes(films);

                ViewData["booksTopLinks"] = helper.getItemTopLinks(books);
                ViewData["booksYouTubes"] = helper.getItemYouTubes(books);

                ViewData["gamesTopLinks"] = helper.getItemTopLinks(games);
                ViewData["gamesYouTubes"] = helper.getItemYouTubes(games);

                ViewData["appsTopLinks"] = helper.getItemTopLinks(apps);
                ViewData["appsYouTubes"] = helper.getItemYouTubes(apps);

                ViewData["recentTopLinks"] = helper.getItemTopLinks(mostRecentItems);
                ViewData["recentYouTubes"] = helper.getItemYouTubes(mostRecentItems);

                return View(new ItemViewModel(songs, films, books, games, apps, mostRecentItems, null, "Global","","",false,"","","",""));
            }
        }
Ejemplo n.º 13
0
 public ActionResult Apps(string Id, string state)
 {
     if (state != "Global")
     {
         DataRepository helper = new DataRepository();
         IList<Item> apps = helper.getSpecificItemsInNetwork(Id, 5,100);
         IList<Item> mostRecentItems = helper.getMostRecentSpecificItemsInNetwork(Id, 5,100);
         string yob = helper.getYOB(Id);
         string stereotype = helper.getStereotype(Id);
         bool male = helper.isMale(Id);
         string recentItem = helper.getMostRecentItem(Id);
         string recentItemId = helper.getMostRecentItemId(Id);
         string location = helper.getLocation(Id);
         ViewData["appsTopLinks"] = helper.getItemTopLinks(apps);
         ViewData["appsYouTubes"] = helper.getItemYouTubes(apps);
         ViewData["recentTopLinks"] = helper.getItemTopLinks(mostRecentItems);
         ViewData["recentYouTubes"] = helper.getItemYouTubes(mostRecentItems);
         ViewData["Following"] = helper.getFollowingCount(Id);
         ViewData["FollowedBy"] = helper.getFollowedByCount(Id);
         return View(new ItemViewModel(null, null, null, null, apps, mostRecentItems, Id, "Network", yob, stereotype, male, recentItem, "",recentItemId,location));
     }
     else//Global State
     {
         DataRepository helper = new DataRepository();
         IList<Item> apps = helper.getSpecificItems(5,100);
         IList<Item> mostRecentItems = helper.getMostRecentSpecificItems(5,100);
         ViewData["appsTopLinks"] = helper.getItemTopLinks(apps);
         ViewData["appsYouTubes"] = helper.getItemYouTubes(apps);
         ViewData["recentTopLinks"] = helper.getItemTopLinks(mostRecentItems);
         ViewData["recentYouTubes"] = helper.getItemYouTubes(mostRecentItems);
         return View(new ItemViewModel(null, null, null, null,apps, mostRecentItems, null, "Global", "", "", false, "", "","",""));
     }
 }
Ejemplo n.º 14
0
        public ActionResult RecSongRequest(string songName,string artistName, string url, string comment)
        {
            //store new item, link and new comment(if not null)
            //HtmlScraper scraper = new HtmlScraper();
            //scraper.ScrapeUrl(url);
            //string body = scraper.GetBody();

            //if (body.Contains(songName) && body.Contains(artistName))
            //{
                DataRepository helper = new DataRepository();
                string name = songName + " by " + artistName;
                string username = Session["Username"].ToString();
                int itemId = helper.AddItem(name, username, 1);

                helper.AddLink(url, itemId, username);

                if (comment != "")
                {
                    helper.AddComment(username, itemId, comment);
                }

            return RedirectToAction("Index", new { Id = Session["Username"].ToString(), state = "Network" });
        }
Ejemplo n.º 15
0
        public ActionResult UserSearch()
        {
            string search = Request.Form["SearchMate"];

            DataRepository helper = new DataRepository();
            if (helper.usernameExists(search))
            {
                return RedirectToAction("Index", new { Id = search,state="User" });
            }
            else
            {
                TempData["UserDoesNotExist"] = "That user does not exist.";
                return RedirectToAction("Index");
            }
        }
Ejemplo n.º 16
0
        public ActionResult Unfollow(string Id)
        {
            string id = Id;
            DataRepository helper = new DataRepository();

            FollowConnection deleteMe2 = helper.getFollowConnectionFromUser(Session["Username"].ToString(),Id);

            helper.deleteConnection(deleteMe2);

            ViewData["Username"] = id;
            ViewData["Following"] = helper.getFollowingCount(Id);
            ViewData["FollowedBy"] = helper.getFollowedByCount(Id);

            return PartialView();
        }
        public ActionResult Unfollow(FollowConnection deleteMe)
        {
            DataRepository helper = new DataRepository();
            helper.deleteConnection(deleteMe);

            return RedirectToAction("Index");
        }
        public ActionResult Unfollow(int Id)
        {
            DataRepository helper = new DataRepository();

            helper.deleteConnectionById(Convert.ToInt32(Id));

            string username = Session["Username"].ToString();
            IList<FollowConnection> friends = helper.getFollowConnections(username);
            ViewData["Friends"] = friends;

            return PartialView();
        }
Ejemplo n.º 19
0
        public ActionResult RecGameRequest(string gameName, string consoleName, string url, string comment)
        {
            //store new item, link and new comment(if not null)
            DataRepository helper = new DataRepository();
            string name = gameName + " on " + consoleName;
            string username = Session["Username"].ToString();
            int itemId = helper.AddItem(name, username, 4);

            helper.AddLink(url, itemId, username);

            if (comment != "")
            {
                helper.AddComment(username, itemId, comment);
            }

            return RedirectToAction("Index", new { Id = Session["Username"].ToString(), state = "Network" });
        }
Ejemplo n.º 20
0
        public ActionResult DeleteLink(string Id, int ItemId)
        {
            DataRepository helper = new DataRepository();

            helper.DeleteLink(Convert.ToInt32(Id));

            IList<Link> links = helper.getLinks(ItemId);

            DiscussionViewModel model = new DiscussionViewModel(-1, null, links, "", "", null, "", "", "", "");

            ViewData["Id"] = Id;

            return PartialView(model);
        }
Ejemplo n.º 21
0
        public ActionResult Discussion(string Id, string state, int itemId)
        {
            DataRepository helper = new DataRepository();

            Item item = helper.getItem(itemId);
            IList<ItemComment> comments = helper.getComments(itemId);
            IList<Link> links = helper.getLinks(itemId);
            string topLink = helper.getTopLink(itemId);
            string youtubeLink = helper.getTopYoutubeLink(itemId);

            DiscussionViewModel model = new DiscussionViewModel(itemId, comments, links, Id, state, item,"","",topLink,youtubeLink);

            return View(model);
        }
Ejemplo n.º 22
0
        public ActionResult Follow(string Id)
        {
            string id = Id;
            DataRepository helper = new DataRepository();
            if (!helper.AlreadyFollowingUser(Session["Username"].ToString(), Id))
                helper.AddFollowConnection(Session["Username"].ToString(), Id);

            ViewData["Username"] = id;
            ViewData["Following"] = helper.getFollowingCount(Id);
            ViewData["FollowedBy"] = helper.getFollowedByCount(Id);

            return PartialView();
        }
Ejemplo n.º 23
0
        public ActionResult SearchGamesMain(string Id, string state)
        {
            string search = Request.Form["search"];

            if (state != "Global" && state != null)
            {
                DataRepository helper = new DataRepository();

                IList<Item> games = helper.getSpecificItemsInNetworkSearch(Id, 4, search, 100);
                if (games.Count() < 1)
                {
                    ViewData["NoResults"] = "Sorry, there are no results for '" + search + "'";
                }
                string yob = helper.getYOB(Id);
                string stereotype = helper.getStereotype(Id);
                bool male = helper.isMale(Id);
                string recentItem = helper.getMostRecentItem(Id);
                string recentItemId = helper.getMostRecentItemId(Id);
                string location = helper.getLocation(Id);

                ViewData["gamesTopLinks"] = helper.getItemTopLinks(games);
                ViewData["gamesYouTubes"] = helper.getItemYouTubes(games);

                return PartialView(new ItemViewModel(null, null, null, games, null, null, Id, "User", yob, stereotype, male, recentItem, "", recentItemId,location));
            }
            else//Global State
            {
                DataRepository helper = new DataRepository();
                IList<Item> games = helper.getSpecificItemsSearch(4, search, 100);
                if (games.Count() < 1)
                {
                    ViewData["NoResults"] = "Sorry, there are no results for '" + search + "'";
                }
                ViewData["gamesTopLinks"] = helper.getItemTopLinks(games);
                ViewData["gamesYouTubes"] = helper.getItemYouTubes(games);

                return PartialView(new ItemViewModel(null, null, null, games, null, null, null, "Global", "", "", false, "", "", "",""));
            }
        }
        public ActionResult RegisterRequest(RegisterViewModel viewModel)
        {
            DataRepository helper = new DataRepository();

            if (viewModel.username == null)
            {
                viewModel.errorMessage = "Please type in a username";
                return RedirectToAction("Register",viewModel);
            }
            else if (viewModel.password != viewModel.retypePassword)
            {
                viewModel.errorMessage = "Make sure both passwords are the same";
                return RedirectToAction("Register",viewModel);
            }
            else if (helper.usernameExists(viewModel.username))
            {
                viewModel.errorMessage = "Sorry, that alias has been taken";
                return RedirectToAction("Register",viewModel);
            }
            else
            {
                helper.AddUser(viewModel);
                helper.FollowSelf(viewModel.username.ToString());
                Session["LoggedIn"] = "true";
                Session["Username"] = viewModel.username.ToString();
                return RedirectToAction("Index", "Home", new { Id = Session["Username"].ToString(), State = "Network" });
            }
        }