Ejemplo n.º 1
0
        public async Task <IndexViewModel> GetIndexViewModelAsync()
        {
            var user = await this.GetApplicationUserAsync();

            var teams = (from registeredUser in this.Database.RegisteredUsers
                         where registeredUser.AspNetUserId == user.Id
                         from rut in registeredUser.Teams
                         select new IndexViewModel.Team
            {
                Id = rut.Team.Id,
                Name = rut.Team.Name
            }).ToArray();

            var activities = await this.GetActivitiesAsync(user.Id);

            var activitiesViewModel = new ActivitiesViewModel {
                Activities = activities
            };

            var newsFeedContents = await this.GetFeedAsync(user.Id);

            var newsFeedViewModel = new NewsFeedViewModel {
                NewsFeed = newsFeedContents
            };

            var calendarViewModel = this.GetCalendarViewModel(nameof(IActivityController.GetCalendarEventsAsync), "User");

            return(new IndexViewModel
            {
                Teams = teams,
                Activities = activitiesViewModel,
                NewsFeed = newsFeedViewModel,
                Calendar = calendarViewModel
            });
        }
Ejemplo n.º 2
0
        // Functions

        public static NewsFeedViewModel CreatePost(CreatePostViewModel creatPostViewModel, HttpPostedFileBase postPhoto)
        {
            using (BewanderContext db = new BewanderContext())
            {
                // GET: Models needed for CreatePostViewModel
                string userID         = creatPostViewModel.UserID;
                User   user           = db.Users.Find(userID);
                Image  profilePicture = Image.GetProfileImages(userID, FileType.ProfilePicture);

                Post newPost = new Post {
                    DatePosted = DateTime.Now, Caption = creatPostViewModel.Caption, UserID = userID
                };
                Image postedPhoto = new Image();

                if (postPhoto != null)
                {
                    Image.SavePhotos(user, postPhoto);
                    postedPhoto     = (Image)db.Users.Find(userID).Files.Last();
                    newPost.PhotoID = postedPhoto.ID;
                }

                db.Posts.Add(newPost);
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                NewsFeedViewModel postDisplayViewModel = new NewsFeedViewModel(user, profilePicture, postedPhoto, newPost);

                return(postDisplayViewModel);
            }
        }
Ejemplo n.º 3
0
 public NewsFeedView()
 {
     InitializeComponent();
     BindingContext = new NewsFeedViewModel();
     vm.LoadNewsFeed();
     lstNewsFeedItems.ItemsSource = vm.NewsFeedItems;
 }
Ejemplo n.º 4
0
        public ActionResult UserStories(string id)
        {
            NewsFeedViewModel model = new NewsFeedViewModel();

            model.UserDisplayed    = UserService.Service.GetUserById(User.Identity.GetUserId());
            model.ProfileDisplayed = UserService.Service.GetUserById(id);
            model.Content          = UserService.Service.GetUserStories(id);
            return(View("UserStories", model));
        }
Ejemplo n.º 5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string myParameterValue = NavigationContext.QueryString["feedName"];

            NewsFeedViewModel newsFeedViewModel = App.NewsFeedViewModel;

            newsFeedViewModel.LoadData(myParameterValue);
            DataContext = newsFeedViewModel;
            base.OnNavigatedTo(e);
        }
Ejemplo n.º 6
0
 public ActionResult CreatePost([Bind(Include = "Caption")] CreatePostViewModel createPostViewModel, HttpPostedFileBase postPhoto)
 {
     if (ModelState.IsValid && (createPostViewModel.Caption != null || postPhoto != null))
     {
         createPostViewModel.UserID = User.Identity.GetUserId();
         NewsFeedViewModel formattedPost = Post.CreatePost(createPostViewModel, postPhoto);
         return(PartialView("_PostDisplay", formattedPost));
     }
     return(null);
 }
Ejemplo n.º 7
0
        /***************** ACTUAL POSTS ************/
        public PartialViewResult _Newsfeed()
        {
            string        userID      = User.Identity.GetUserId();
            List <string> friendsList = RelationshipViewModel.GetFriendsID(userID);

            friendsList.Add(userID);
            List <NewsFeedViewModel> postList = NewsFeedViewModel.GetNewsFeed(friendsList);

            return(PartialView("_Newsfeed", postList));
        }
Ejemplo n.º 8
0
        public ActionResult Index()
        {
            PhotoRepository repo = new PhotoRepository();
            string          user = User.Identity.GetUserName();

            NewsFeedViewModel model = new NewsFeedViewModel();

            model.photo = repo.GetFollowersPhotos(user);
            return(View(model));
        }
        public ActionResult UserNewsfeed()
        {
            string            currentUserId = User.Identity.GetUserId();
            NewsFeedViewModel model         = new NewsFeedViewModel();

            model.UserDisplayed    = UserService.Service.GetUserById(currentUserId);
            model.ProfileDisplayed = model.UserDisplayed;
            model.Content          = UserService.Service.GetNewsFeedItemsForUser(currentUserId);
            return(View("UserNewsfeed", model));
        }
Ejemplo n.º 10
0
        public AnnounPage()
        {
            InitializeComponent();
            BindingContext = newsFeedVM = new NewsFeedViewModel(this);
            //this.SlideMenu = new DrawerPage();
            Title = "Duyurular";

            MessagingCenter.Subscribe <TabControl, bool>(this, MCenter.tabListResetKey.ToString(), (arg1, arg2) =>
            {
                newsFeedVM.scroolListView(listViewFeed);
            });
        }
Ejemplo n.º 11
0
        public ActionResult UserWall(string id)
        {
            NewsFeedViewModel wallContent = new NewsFeedViewModel();

            wallContent.UserDisplayed    = UserService.Service.GetUserById(User.Identity.GetUserId());
            wallContent.ProfileDisplayed = UserService.Service.GetUserById(id);
            wallContent.Content          = UserService.Service.GetWallContentForUser(id);
            wallContent.ActionName       = this.ControllerContext.RouteData.Values["action"].ToString();
            wallContent.ControllerName   = this.ControllerContext.RouteData.Values["controller"].ToString();
            wallContent.RouteValue       = wallContent.ProfileDisplayed.Id;

            return(View(wallContent));
        }
Ejemplo n.º 12
0
        private async void Login(object sender, TappedRoutedEventArgs e)
        {
            bool result = await UserRepository.login(loginEmail.Text, loginWw.Password);

            if (result)
            {
                loginEmail.Text  = "";
                loginWw.Password = "";
            }
            btnLogin.Content = result ? "afmelden": "login";
            vm = DataContext as NewsFeedViewModel;
            vm.setIsAdmin(result);
        }
Ejemplo n.º 13
0
        public IActionResult NewsFeedViewTest(NewsFeedViewModel newsFeedViewModel)
        {
            //var timeStamp = new DateTime();
            //timeStamp = newsFeedViewModel.Collaborations.Where(t => t.WhenCreated == DateTime.Today);

            //var thing = new NewsFeedViewModel();
            //thing = newsFeedViewModel.Collaboration.Collaborations.Where(x => x.WhenCreated == DateTime.Now);
            ////thing = newsFeedViewModel.Collaborations.Where(x => x.WhenCreated == DateTime.Now);

            //thing = newsFeedViewModel.Collaborations.Where(x => x.WhenCreated == DateTime.Now);

            //return View(thing);


            return(View());
        }
Ejemplo n.º 14
0
 public NewsFeedPage(INavigation _navi)
 {
     Title = Properties.Resources.PageNameNewsFeed;
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     BindingContext         = new NewsFeedViewModel(_navi, this);
     NewsList.ItemSelected += (sender, e) =>
     {
         ((ListView)sender).SelectedItem = null;
     };
     MessagingCenter.Subscribe <NewsFeedViewModel, string>(this, Properties.Resources.MsgNetworkError,
                                                           async(sender, message) =>
     {
         await this.DisplayAlert("Problem z siecią", message, "OK");
     });
 }
Ejemplo n.º 15
0
        public ActionResult GroupWall(int?id)
        {
            if (id.HasValue)
            {
                string            currentUserId = User.Identity.GetUserId();
                NewsFeedViewModel model         = new NewsFeedViewModel();
                model.GroupDisplayed = GroupService.Service.GetGroupById(id.Value);
                model.Content        = GroupService.Service.GetNewsfeedItemsForGroup(id.Value);
                model.UserDisplayed  = UserService.Service.GetUserById(currentUserId);
                model.ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                model.ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                model.RouteValue     = model.GroupDisplayed.Id.ToString();

                return(View("GroupWall", model));
            }

            return(RedirectToAction("GroupList"));
        }
Ejemplo n.º 16
0
        private UIViewController CreateTabFor(NewsFeedViewModel viewModel)
        {
            var controller = new UINavigationController();

            if (this.CreateViewControllerFor(viewModel) is UIViewController screen)
            {
                UIImage image = null;

                if (viewModel.Feed.IconPath != null)
                {
                    image = UIImage.FromFile(this.cache.Map(viewModel.Feed.IconPath))?.Scale(new CGSize(25, 25), UIScreen.MainScreen.Scale);
                }

                screen.NavigationItem.Title = viewModel.Title;
                controller.TabBarItem       = new UITabBarItem(viewModel.Title, image, this.tabCount++);

                controller.PushViewController(screen, false);
            }

            return(controller);
        }
        public async Task <IActionResult> DataAnalysis(NewsFeedViewModel newsFeedViewModel)
        {
            NewsFeedViewModel beerFanTastes = new NewsFeedViewModel();
            //Needs to display total BeerFanTaste likes
            int countOfAleLovers     = _context.Fan.Where(bft => bft.LikesAle == true).Count();
            int countOfLagerLovers   = _context.Fan.Where(bft => bft.LikesLager == true).Count();
            int countOfIPALovers     = _context.Fan.Where(bft => bft.LikesIPA == true).Count();
            int countOfStoutLovers   = _context.Fan.Where(bft => bft.LikesStout == true).Count();
            int countOfPaleAleLovers = _context.Fan.Where(bft => bft.LikesPaleAle == true).Count();
            int countOfWheatLovers   = _context.Fan.Where(bft => bft.LikesWheatBeer == true).Count();
            int countOfPilsnerLovers = _context.Fan.Where(bft => bft.LikesPilsner == true).Count();
            int countOfPorterLovers  = _context.Fan.Where(bft => bft.LikesPorter == true).Count();
            int countOfSoursLovers   = _context.Fan.Where(bft => bft.LikesSour == true).Count();
            int countOfSaisonLovers  = _context.Fan.Where(bft => bft.LikesSaison == true).Count();

            //Needs to display total Brewery Followers
            //int countOfBreweryFollowers = _context.Follow.Select(bf => bf.BreweryId).Where(bf => bf.IsFollowed).Count();
            //needs to match BeerFanTaste likes with Brewery Beer Styles
            //Needs to match BeerFanTaste likes with Collaboration Beer Styles
            //needs to match breweries with same beer styles in brewery beers
            return(View(newsFeedViewModel));
        }
        public async Task TestUrl()
        {
            // Setup
            var data = await this.GetRelativeDummyNewsAsync(DateTime.Now);

            var news = data.First();

            var viewModel = new NewsFeedViewModel(null, null, null, this.MockWebBrowserTask.Object);

            // Exercise
            viewModel.ShowDetail(new SqlNews()
            {
                Date    = news.Date,
                FeedKey = "Test",
                NewsId  = news.NewsId,
                Title   = news.Title,
                Url     = news.Url,
                Message = news.Message
            });

            // Verify
            this.MockWebBrowserTask.Verify(t => t.ShowWebPage(news.Url), Times.Once);
        }
Ejemplo n.º 19
0
        // GET: NewsFeed
        public JsonResult NewsFeedIndex()
        {
            NewsFeedViewModel result = new NewsFeedViewModel();

            result.NewsItems = dB.NewsFeedItems
                               .Select(item => new NewsItemDTO
            {
                ItemId                = item.ItemId,
                Title                 = item.Title,
                ItemContent           = item.ItemContent,
                TimeStamp             = item.TimeStamp,
                EventDateTime         = item.EventDateTime,
                Organizer             = item.Organizer,
                OrganizerContactEmail = item.OrganizerContactEmail,
                IsEvent               = item.IsEvent,
            })
                               .OrderByDescending(n => n.TimeStamp).ToList();

            result.IsAdminOrMod = User.IsInRole("Admin") || User.IsInRole("Moderator");


            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 20
0
        public PartialViewResult _Posts(string userID)
        {
            string                   currentUserID     = User.Identity.GetUserId();
            ICollection <Post>       postsList         = db.Posts.SqlQuery("dbo.Post_Search @p0", userID).ToList();
            List <NewsFeedViewModel> formattedPostList = new List <NewsFeedViewModel>();

            foreach (Post post in postsList)
            {
                User              user           = db.Users.SqlQuery("dbo.User_Select @p0", userID).SingleOrDefault();
                Image             profilePicture = Image.GetProfileImages(userID, FileType.ProfilePicture);
                Image             postedPicture  = (post.PhotoID != null) ? db.Images.SqlQuery("dbo.Photo_Select @p0", post.PhotoID).SingleOrDefault() : new Image();
                NewsFeedViewModel formattedPost  = new NewsFeedViewModel(user, profilePicture, postedPicture, post);
                formattedPostList.Add(formattedPost);
            }
            if (userID == currentUserID)
            {
                Session["Reviews"] = "self";
            }
            else
            {
                Session["Reviews"] = "user";
            }
            return(PartialView("ProfilePage/_Posts", formattedPostList.OrderByDescending(i => i.PostID)));
        }
Ejemplo n.º 21
0
 private void Loguit(object sender, TappedRoutedEventArgs e)
 {
     UserRepository.loguit();
     vm = DataContext as NewsFeedViewModel;
     vm.loguit();
 }
Ejemplo n.º 22
0
 public NewsFeedPage(NewsFeedViewModel newsFeedViewModel)
 {
     BindingContext = newsFeedViewModel;
     InitializeComponent();
 }
Ejemplo n.º 23
0
        public ActionResult NewsFeed(string username)
        {
            _viewModel = new NewsFeedViewModel();
            CreateLayoutView("Trang cá nhân");
            if (username == "false")
            {
                username = _viewModel.User.UserName;
            }
            ApplicationUser userCur = _service.GetUserByUserName(username);

            FieldHelper.CopyNotNullValue(NewsFeedViewModel, userCur);

            List <Post> listPost = new List <Post>();

            listPost = _postService.getPostByUser(userCur.Id).Take(5).ToList();
            NewsFeedViewModel.ListPostType = _postTypeService.GetAll().ToList();

            foreach (Post post in listPost)
            {
                PostViewModel   postViewModel = new PostViewModel();
                ApplicationUser user          = _service.GetUserById(post.Id_User);
                FieldHelper.CopyNotNullValue(postViewModel, user);
                FieldHelper.CopyNotNullValue(postViewModel, post);

                postViewModel.TypeToString = _postTypeService.GetById(post.Id_Type).Name;
                PostVoteDetail votePost = _postVoteDetailService.getVoteByIdUser(NewsFeedViewModel.Id, post.Id);
                if (votePost != null)
                {
                    postViewModel.Vote = votePost.Vote;
                }
                List <Comment> listComment      = new List <Comment>();
                List <Comment> listChildComment = new List <Comment>();
                listComment = _commentOfPost.getCommentOfPost(post.Id);
                foreach (var parent in listComment)
                {
                    CommentViewModel commentViewModel = new CommentViewModel();
                    user = _service.GetUserById(parent.Id_User);
                    CommentVoteDetail voteComment = _commentVoteDetailService.getVoteByIdUser(NewsFeedViewModel.Id, parent.Id);
                    if (voteComment != null)
                    {
                        commentViewModel.Vote = voteComment.Vote;
                    }
                    FieldHelper.CopyNotNullValue(commentViewModel, user);
                    FieldHelper.CopyNotNullValue(commentViewModel, parent);
                    listChildComment = _commentOfPost.getChildOfComment(parent.Id_Post, parent.Id);
                    if (listChildComment.Count != 0)
                    {
                        foreach (var child in listChildComment)
                        {
                            CommentViewModel commentChildViewModel = new CommentViewModel();
                            user = _service.GetUserById(child.Id_User);
                            FieldHelper.CopyNotNullValue(commentChildViewModel, user);
                            FieldHelper.CopyNotNullValue(commentChildViewModel, child);
                            commentViewModel.listChildComment.Add(commentChildViewModel);
                        }
                    }
                    if (commentViewModel.Corrected)
                    {
                        postViewModel.listComment.Insert(0, commentViewModel);
                    }
                    else
                    {
                        postViewModel.listComment.Add(commentViewModel);
                    }
                }
                NewsFeedViewModel.ListPost.Add(postViewModel);
            }
            List <String> listFriend = _friendService.GetAllFriend(userCur.Id);

            foreach (String friend in listFriend)
            {
                FriendViewModel friendViewModel = new FriendViewModel();
                ApplicationUser user            = _service.GetUserById(friend);
                FieldHelper.CopyNotNullValue(friendViewModel, user);
                NewsFeedViewModel.ListFriend.Add(friendViewModel);
            }
            return(PartialView("_NewsFeed", NewsFeedViewModel));
        }
Ejemplo n.º 24
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            BindingContext = new NewsFeedViewModel(Navigation);
        }
        public async Task <IActionResult> FollowersCount(NewsFeedViewModel newsFeedViewModel)
        {
            IEnumerable <Brewery> BreweryList = await _context.Brewery.Include(s => s.Followers).ToListAsync();

            foreach (Brewery brewery in BreweryList)
            {
                //Query for fans by looking at follows that have the same BreweryId as the one being looked at in that loop
                brewery.Followers = _context.Fan.Where(fa => (_context.Follow.Where(fo => fo.BreweryId == brewery.Id).Select(fo => fo.FanFollowerId).Contains(fa.Id))).ToList();
                return(View(BreweryList));
            }


            newsFeedViewModel.Brewery.ApplicationId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            //query for the Brewery object that is currently logged in
            //string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            //Brewery loggedInBrewery = _context.Brewery.Where(i => i.ApplicationId == userId).SingleOrDefault();
            Follow followers = _context.Follow.Where(f => f.ApplicationId == newsFeedViewModel.Brewery.ApplicationId).SingleOrDefault();

            //    //query for a count of followers per each brewery
            //int followersCount = _context.Follow.Where(bf => bf.BreweryId == true);



            if (followers == null)
            {
                return(NotFound());
            }
            else
            {
                //get id of brewery whos follows we want to count
                //NewsFeedViewModel followBreweryId = _context.Follow.Where(f => f.BreweryId == Brewery.Id).Count();
                //NewsFeedViewModel breweryFollowers = _context..Where(f => f.BreweryId == this. ).Count();
                //int fansOfLakefront = _context.Follow.Where(f => f.IsFollowed == true).Count();
                //int fansOfMobCraft = _context.Follow.Where(f => f.MobCraftBrewery == true).Count();
                //int fansOfBrokenBat = _context.Follow.Where(f => f.BrokenBatBrewery == true).Count();

                //get count of Beer Fan Taste likes
                int countOfAleLovers          = _context.BeerFanTaste.Where(bft => bft.Ale == true).Count();
                int countOfLagerLovers        = _context.BeerFanTaste.Where(bft => bft.Lager == true).Count();
                int countOfIndiaPaleAleLovers = _context.BeerFanTaste.Where(bft => bft.IndiaPaleAle == true).Count();
                int countOfStoutLovers        = _context.BeerFanTaste.Where(bft => bft.Stout == true).Count();
                int countOfPaleAleLovers      = _context.BeerFanTaste.Where(bft => bft.PaleAle == true).Count();
                int countOfWheatBeerLovers    = _context.BeerFanTaste.Where(bft => bft.WheatBeer == true).Count();
                int countOfPilsnerLovers      = _context.BeerFanTaste.Where(bft => bft.Pilsner == true).Count();
                int countOfPorterLovers       = _context.BeerFanTaste.Where(bft => bft.Porter == true).Count();
                int countOfSourLovers         = _context.BeerFanTaste.Where(bft => bft.Sour == true).Count();
                int countOfSaisonLovers       = _context.BeerFanTaste.Where(bft => bft.Saison == true).Count();
            }

            return(View());

            //gets followers if the followers are bools
            //followers.BreweryId = newsFeedViewModel.Brewery.Id;
            //followers.BrokenBatBrewery = newsFeedViewModel.Follow.BrokenBatBrewery;
            //followers.LakefrontBrewery = newsFeedViewModel.Follow.LakefrontBrewery;
            //followers.MobCraftBrewery = newsFeedViewModel.Follow.MobCraftBrewery;


            //Follow followersCount = _context.Follow.Where(f => f. == id).SingleOrDefault();


            //    // int countOfAleLovers = _context.BeerFanTaste.Where(bft => bft.Ale == true).Count();
            //    return null;



            //    //query for beers that have the matching FK, put them inICollection<BreweryBeer> BreweryBeers


            //}
        }
 public NewsFeedPage()
 {
     InitializeComponent();
     BindingContext = vm = new NewsFeedViewModel();
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArticleListPage" /> class.
 /// </summary>
 public NewsFeedPage()
 {
     InitializeComponent();
     BindingContext = new NewsFeedViewModel(Navigation);
 }
Ejemplo n.º 28
0
        public ActionResult NewsFeed()
        {
            // Fill in the newsfeed viewmodel to display on the newsfeed
            var userService = new UserService(DbContext);
            var newsFeed    = new NewsFeedViewModel
            {
                Id    = "-1",
                Posts = new List <PostsViewModel>(),
                User  = new UserViewModel()
                {
                    ProfilePicture = userService.GetProfilePicture(User.Identity.GetUserId()).PhotoPath
                }
            };

            var postService        = new PostService(DbContext);
            var likedislikeService = new LikeDislikeService(DbContext);
            var postList           = userService.GetEveryNewsFeedPostsForUser(User.Identity.GetUserId());

            foreach (var id in postList)
            {
                var post = postService.GetPostById(id);

                // Assign a smiley according to if this user has liked or dislike or not done either
                string lPic = null, dPic = null;
                if (likedislikeService.GetLikeDislike(User.Identity.GetUserId(), id) == null)
                {
                    lPic = "~/Content/images/smileySMALL.png";
                    dPic = "~/Content/images/sadfaceSMALL.png";
                }
                else if (likedislikeService.GetLikeDislike(User.Identity.GetUserId(), id).Like)
                {
                    lPic = "~/Content/images/smileyGREEN.png";
                    dPic = "~/Content/images/sadfaceSMALL.png";
                }
                else if (likedislikeService.GetLikeDislike(User.Identity.GetUserId(), id).Dislike)
                {
                    lPic = "~/Content/images/smileySMALL.png";
                    dPic = "~/Content/images/sadfaceRED.png";
                }

                newsFeed.Posts.Add(
                    new PostsViewModel()
                {
                    PostId             = id,
                    Body               = post.Text,
                    DateInserted       = post.Date,
                    LikeDislikeComment = new LikeDislikeCommentViewModel()
                    {
                        Likes    = postService.GetPostsLikes(post.PostId),
                        Dislikes = postService.GetPostsDislikes(post.PostId),
                        Comments = postService.GetPostsCommentsCount(post.PostId)
                    },
                    User = new UserViewModel()
                    {
                        UserId         = post.UserId,
                        Name           = userService.GetUserById(post.UserId).Name,
                        ProfilePicture = userService.GetProfilePicture(post.UserId).PhotoPath
                    },
                    LikePic    = lPic,
                    DislikePic = dPic
                });
            }

            return(View(newsFeed));
        }
Ejemplo n.º 29
0
 public NewsFeedPage()
 {
     this.InitializeComponent();
     ViewModel = new NewsFeedViewModel();
 }
Ejemplo n.º 30
0
        public PartialViewResult _Comment(string postID)
        {
            NewsFeedViewModel newsFeedViewModel = new NewsFeedViewModel();

            return(PartialView("_Comment", newsFeedViewModel));
        }