예제 #1
0
        public ActionResult _FriendList()
        {
            FriendViewModel friendModel = new FriendViewModel();

            friendModel.listModel = _userService.GetFriends().Select(x => new ItemFriendViewModel
            {
                ID = x.ID,
                Friend_ID = x.Friend_ID,
                Friend_Login = x.Friend_Login,
                Accepted = x.OrAccepted ? "Tak" : "Nie",
                User_ID = x.User_ID,
                User_Login = x.User_Login
            }).ToList();

            friendModel.allUser = _userService.GetUser().Select(x => x.Login).ToArray();

            return View(friendModel);
        }
예제 #2
0
        public ActionResult AddFriendAdmin(FriendViewModel friendModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            FriendDto friendDto = new FriendDto();

            friendDto.ID = friendModel.viewModel.ID;
            friendDto.Friend_Login = friendModel.viewModel.Friend_Login;
            friendDto.User_Login = friendModel.viewModel.User_Login;
            friendDto.OrAccepted = friendModel.viewModel.Accepted.ToLower().Contains("tak") ? true : false;

            if(_userService.AddFriendAdmin(friendDto))
            {
                errors.Add("Dodano znajomych.");
            }
            else
            {
                errors.Add("Błąd. Spróbuj ponownie.");
            }
            Session["val"] = errors.ToArray<string>();

            return RedirectToAction("Admin");
        }
예제 #3
0
        public ActionResult _FriendList()
        {
            FriendViewModel friendModel = new FriendViewModel();

            friendModel.listModel = _userService.GetFriendList(User.Identity.Name).Select(x => new ItemFriendViewModel
            {
                ID = x.ID,
                User_Login = x.User_Login,
                User_ID = x.User_ID,
                Friend_ID = x.Friend_ID,
                Friend_Login = x.Friend_Login,
                OrAccepted = x.OrAccepted
            }).ToList();

            return View(friendModel);
        }