Exemple #1
0
        public IActionResult Wall(WallViewModel wallViewModel)
        {
            if (!ModelState.IsValid)
            {
                wallViewModel.Posts = _postService.Posts;

                return(View(wallViewModel));
            }

            var newPost = new Post();

            newPost.Content = wallViewModel.Content;

            var user = _userService.GetUser(User.Identity.Name);

            newPost.User = user;

            newPost = _postService.AddWithCommit(newPost);

            _userService.AddPost(user, newPost);

            _ccDbContextService.Commit();

            wallViewModel.Posts = _postService.Posts;

            return(View(wallViewModel));
        }
Exemple #2
0
        public IActionResult Index(string name)
        {
            if (name != User.Identity.Name)
            {
                return(RedirectToAction("Wall", "Home"));
            }

            var user = _userService.GetUser(name);

            var messages = _messageService.Messages
                           .Where(m => m.UserReceiver.Id == user.Id || m.UserSender.Id == user.Id)
                           .ToList();

            messages.All(x => x.IsRead = true);
            _ccDbContextService.Commit();


            var model = new IndexViewModel
            {
                user     = user,
                Messages = messages
            };

            return(View(model));
        }
        public IActionResult Index(string name)
        {
            if (User.Identity.Name != name)
            {
                return(RedirectToAction("Wall", "Home"));
            }

            var notifications = _notificationService.Notifications.Where(n => n.NotifiedUser.UserName == name).ToList();

            notifications.All(x => x.IsRead = true);

            _ccDbContextService.Commit();

            var model = new IndexViewModel()
            {
                Notifications = notifications
            };

            return(View(model));
        }