Beispiel #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));
        }
        // GET: Wall
        public ActionResult Index(string username)
        {
            var posts     = postRepository.GetPostsOnWall(username);
            var viewModel = new WallViewModel(posts, username);

            return(View(viewModel));
        }
 public ActionResult AddDislike(WallViewModel wallViewModel)
 {
     postRepository.AddDislike(new Post {
         post_id = wallViewModel.post_id
     });
     return(RedirectToAction("Index", new { username = wallViewModel.OwnerUsername }));
 }
Beispiel #4
0
 public ActionResult DeleteWall(WallViewModel wallViewModel)
 {
     postRepository.DeletePost(new Post {
         id = wallViewModel.id
     });
     return(RedirectToAction("Index", new { username = wallViewModel.OwnerUsername, fullname = wallViewModel.fullname }));
 }
        public IActionResult CreateComment(WallViewModel viewModel, int MessageId)
        {
            if (HttpContext.Session.GetInt32("userInSess") == null)
            {
                TempData["error"] = "You must be logged in to do that";
                return(RedirectToAction("Index"));
            }
            if (ModelState.IsValid)
            {
                viewModel.Comment.MessageId = MessageId;
                viewModel.Comment.UserId    = (int)HttpContext.Session.GetInt32("userInSess");

                System.Console.WriteLine("PLEASE GET HERE ########################################");
                System.Console.WriteLine(viewModel);
                System.Console.WriteLine(viewModel.Comment);
                System.Console.WriteLine(viewModel.Comment.MessageId);
                System.Console.WriteLine(viewModel.Comment.UserId);
                System.Console.WriteLine(viewModel.Comment.commentContent);
                System.Console.WriteLine("PLEASE GET HERE ########################################");

                dbContext.Comments.Add(viewModel.Comment);
                dbContext.SaveChanges();

                return(RedirectToAction("Wall"));
            }
            return(View("Wall"));
        }
Beispiel #6
0
        public IActionResult Wall()
        {
            var model = new WallViewModel();

            model.Posts = _postService.Posts;

            return(View(model));
        }
        public WallViewModel GetWallData()
        {
            var wall = new WallViewModel
            {
                Statuses = _statusQueryService.GetStatuses()
            };

            return(wall);
        }
        public ActionResult NewWave(WallViewModel wallViewModel)
        {
            var username = User?.Identity?.Name;;

            postRepository.CreatePost(new Post()
            {
                post_content = wallViewModel.OwnerUsername + " sent a 👋", recipient = wallViewModel.OwnerUsername, sender = username
            });
            return(RedirectToAction("Index", new { username = wallViewModel.OwnerUsername }));
        }
Beispiel #9
0
        public ActionResult NewWall(WallViewModel wallViewModel)
        {
            var username = AuthenticationHelper.ExtractUsernameAndPassword(Request).Username;

            postRepository.CreatePost(new Post()
            {
                Content = wallViewModel.NewPost, Recipient = wallViewModel.OwnerUsername, Sender = username
            });
            return(RedirectToAction("Index", new { username = wallViewModel.OwnerUsername, fullname = wallViewModel.fullname }));
        }
Beispiel #10
0
        // GET: Wall
        public ActionResult Index(string username, string fullname)
        {
            var posts     = postRepository.GetPostsOnWall(username);
            var viewModel = new WallViewModel(posts, username);

            viewModel.fullname      = fullname;
            viewModel.OwnerUsername = username;
            viewModel.LoggedInUser  = AuthenticationHelper.ExtractUsernameAndPassword(request: Request)?.Username;

            return(View(viewModel));
        }
Beispiel #11
0
 public IActionResult CreateMessage(WallViewModel viewModel)
 {
     if (HttpContext.Session.GetInt32("InSession") == null)
     {
         TempData["error"] = "You must be logged in to access this page";
         return(RedirectToAction("Index"));
     }
     viewModel.Message.UserId = (int)HttpContext.Session.GetInt32("InSession");
     dbContext.Messages.Add(viewModel.Message);
     dbContext.SaveChanges();
     return(RedirectToAction("Wall"));
 }
Beispiel #12
0
        public T Invoke()
        {
            Guard.InstanceNotNull(OnComplete, "OnComplete");

            var result = serviceRegistry.StaffService.LoadStaffTypes();

            var viewModel = new WallViewModel
            {
                StaffTypes = result.StaffTypes
            };

            return(OnComplete(viewModel));
        }
        public ActionResult Index(string username)
        {
            if (username == null)
            {
                username = User?.Identity?.Name;
            }
            var user      = userRepository.Login(username);
            var posts     = postRepository.GetPostsOnWall(username);
            var viewModel = new WallViewModel(posts, username);

            viewModel.firstname = user.firstname;
            viewModel.surname   = user.surname;

            return(View(viewModel));
        }
Beispiel #14
0
        public WallViewModel GetPostsForUser(int userId)
        {
            WallViewModel result = new WallViewModel();

            result.Posts = context.Posts.Include(p => p.Author)
                           .Include(p => p.Comments)
                           .Include(p => p.ToUser)
                           .Where(p => p.ToUser != null)
                           .Where(p => p.ToUser.Id == userId)
                           .OrderByDescending(p => p.PublishedDate)
                           .Select(p => UserMapping.MapPostViewModelFromDb(p))
                           .ToList();

            return(result);
        }
        public ActionResult NewWall(WallViewModel wallViewModel)
        {
            string username = User?.Identity?.Name;
            User   user     = new User();
            User   receiver = new User();

            //get user object from repositry by username to display user.fullname
            user     = userRepository.GetSingleUser(username);
            receiver = userRepository.GetSingleUser(wallViewModel.OwnerUsername);

            postRepository.CreatePost(new Post()
            {
                Content = wallViewModel.NewPost, Recipient = receiver.username, Sender = user.username
            });
            return(RedirectToAction("Index", new { username = wallViewModel.OwnerUsername }));
        }
Beispiel #16
0
 public IActionResult CreateComment(WallViewModel viewModel, int MessageId)
 {
     if (HttpContext.Session.GetInt32("InSession") == null)
     {
         TempData["error"] = "You must be logged in to access this";
         return(RedirectToAction("Index"));
     }
     if (ModelState.IsValid)
     {
         viewModel.Comment.MessageId = MessageId;
         viewModel.Comment.UserId    = (int)HttpContext.Session.GetInt32("InSession");
         dbContext.Comments.Add(viewModel.Comment);
         dbContext.SaveChanges();
         return(RedirectToAction("Wall"));
     }
     return(View("Wall"));
 }
Beispiel #17
0
        public IActionResult Wall(string user_id, string guest_id)
        {
            //// Get Users
            var owner = _userService.Get(user_id);
            var guest = _userService.Get(guest_id);

            if (owner == null || guest == null)
            {
                return(RedirectToAction("Index"));
            }

            //// Get posts on wall
            var wallPosts = _queryService.GetWall(user_id, guest_id);

            var vm = new WallViewModel(wallPosts, owner, guest);

            return(View(vm));
        }
Beispiel #18
0
 public IActionResult postMessage(WallViewModel vm)
 {
     if (ModelState.IsValid)
     {
         int?currUserId = HttpContext.Session.GetInt32("UserId");
         if (currUserId == null)
         {
             return(Redirect("/"));
         }
         Message msg = vm.newMsg;
         msg.UserId    = (int)currUserId;
         msg.CreatedAt = DateTime.Now;
         dbContext.Messages.Add(msg);
         dbContext.SaveChanges();
         return(Redirect("Wall"));
     }
     return(View("Wall", vm));
 }
Beispiel #19
0
        public IActionResult Wall()
        {
            int?currUserId = HttpContext.Session.GetInt32("UserId");

            if (currUserId == null)
            {
                return(Redirect("/"));
            }
            WallViewModel vm = new WallViewModel();

            vm.messages = dbContext.Messages
                          .Include(m => m.user)
                          .Include(c => c.Comments)
                          .ThenInclude(cu => cu.user)
                          .OrderByDescending(d => d.CreatedAt).ToList();
            vm.currUser = dbContext.Users.FirstOrDefault(u => u.UserId == currUserId);
            return(View("Wall", vm));
        }
        // GET: Wall
        public ActionResult Index(string username)
        {
            User user = new User();

            user = userRepository.GetSingleUser(username);
            var posts = postRepository.GetPostsOnWall(user.username); //gets posts on wall by username

            foreach (var post in posts)                               //converts usernames on posts to fullnames on posts before displaying them.
            {
                User receiver = userRepository.GetSingleUser(post.Recipient);
                post.Recipient = receiver.fullname;
                User sender = userRepository.GetSingleUser(post.Sender);
                post.Sender = sender.fullname;
            }
            var viewModel = new WallViewModel(posts, user);

            return(View(viewModel));
        }
Beispiel #21
0
        public IActionResult Wall()
        {
            if (HttpContext.Session.GetInt32("InSession") == null)
            {
                TempData["error"] = "You must be logged in to access this page";
                return(RedirectToAction("Index"));
            }
            WallViewModel viewModel = new WallViewModel();

            viewModel.User     = dbContext.Users.FirstOrDefault(u => u.UserId == HttpContext.Session.GetInt32("InSession"));
            viewModel.Messages = dbContext.Messages
                                 .Include(m => m.User)
                                 .Include(m => m.Comments)
                                 .ThenInclude(c => c.User)
                                 .OrderByDescending(x => x.CreatedAt)
                                 .ToList();
            return(View("Wall", viewModel));
        }
Beispiel #22
0
 public IActionResult postComment(WallViewModel vm)
 {
     if (ModelState.IsValid)
     {
         int?currUserId = HttpContext.Session.GetInt32("UserId");
         if (currUserId == null)
         {
             return(Redirect("/"));
         }
         Comment cmt = vm.newCmt;
         Message msg = dbContext.Messages.FirstOrDefault(m => m.Id == cmt.MessageId);
         cmt.UserId    = (int)currUserId;
         cmt.user      = dbContext.Users.FirstOrDefault(u => u.UserId == cmt.UserId);
         cmt.CreatedAt = DateTime.Now;
         //msg.Comments.Add(cmt);
         dbContext.Comments.Add(cmt);
         dbContext.SaveChanges();
         return(Redirect("Wall"));
     }
     return(View("Wall", vm));
 }
Beispiel #23
0
        public IActionResult Wall(string projectKey)
        {
            var serverEndpoint = _configurationHelper.JiraServerEndpoint;

            WallViewModel model;

            try
            {
                var inProgressIssues = _jiraIssueService.GetInProgressForProject(projectKey);
                var inReviewIssues   = _jiraIssueService.GetInReviewForProject(projectKey);
                var doneIssues       = _jiraIssueService.GetDoneForProject(projectKey);

                var allIssues = inProgressIssues.Concat(inReviewIssues).Concat(doneIssues);

                model = new WallViewModel(serverEndpoint, projectKey, allIssues);
            }
            catch (Exception e)
            {
                model = new WallViewModel(e.Message);
            }

            return(View(model));
        }
Beispiel #24
0
        public static Wall ToEntityModel(this WallViewModel wallViewModel, Wall wall)
        {
            Mapper.Map(wallViewModel, wall);

            return(wall);
        }
        /*
         * Sidan där man kan se sin egen och andras väggar med meddelanden.
         * Om parameter ej skickas med visas den egna väggen, samt om man söker på sitt namn visar man egna profilen fast via parameter.
         * Skickas en parameter med visas den användarens vägg.
         */

        public ActionResult Index(int?profileId)
        {
            var shownProfile = _DatingContext.Profiles.SingleOrDefault(p => p.Email == User.Identity.Name);

            ViewBag.AddFriend = false;
            if (User.Identity.Name != null && shownProfile != null)
            {
                FriendRequestVisible();
                var messageList = new List <DataLayer.Models.Message>();
                if (profileId != null)
                {
                    AddFriendVisible((int)profileId);
                    messageList  = _DatingContext.Messages.Where(x => x.ReceiverId == profileId).ToList();
                    shownProfile = _DatingContext.Profiles.SingleOrDefault(p => p.Id == profileId);
                }
                else
                {
                    messageList = _DatingContext.Messages.Where(x => x.ReceiverId == shownProfile.Id).ToList();
                }
                //Skapar ny profil för den som ska visas
                Profile profile = new Profile()
                {
                    Id                = shownProfile.Id,
                    Firstname         = shownProfile.Firstname,
                    Lastname          = shownProfile.Lastname,
                    Age               = shownProfile.Age,
                    Email             = shownProfile.Email,
                    Gender            = shownProfile.Gender,
                    SexualOrientation = shownProfile.SexualOrientation,
                    ImagePath         = shownProfile.ImagePath
                };
                var            profiles        = _DatingContext.Profiles.ToList();
                List <Message> currentMessages = new List <Message>();
                //Fyller tomma listan med nya meddelanden från databasen och ger dem en author genom
                //att jämföra SenderId med profilerna i profiles-listan
                foreach (var m in messageList)
                {
                    Message message = new Message()
                    {
                        MessageId  = m.MessageId,
                        SenderId   = m.SenderId,
                        ReceiverId = m.ReceiverId,
                        Text       = m.Text,
                        Date       = m.Date,
                        Author     = profiles.Single(x => x.Id == m.SenderId).Firstname + " " + profiles.Single(x => x.Id == m.SenderId).Lastname
                    };
                    currentMessages.Add(message);
                }
                ;
                //Skapar en viewmodel och fyller den med profil och profilens meddelanden
                WallViewModel wallViewModel = new WallViewModel()
                {
                    Profile      = profile,
                    WallMessages = currentMessages
                };
                return(View(wallViewModel));
            }
            //Om ej inloggad och ej profil
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #26
0
 public WallView(WallViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Beispiel #27
0
        public static WallDTO ToDTO(this WallViewModel wallViewModel)
        {
            var wallDTO = Mapper.Map <WallDTO>(wallViewModel);

            return(wallDTO);
        }