Пример #1
0
 public ActionResult UserManager(User user)
 {
     user.UserId = (int)Session["LoggedUserId"];
     user.RoleId = (int)Session["LoggedUserRole"];
     _userRepository.InsertOrUpdate(user);
     _userRepository.Save();
     return(RedirectToAction("UserManager", "User", new { id = Session["LoggedUserId"] }));
 }
Пример #2
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         _userRepository.InsertOrUpdate(user);
         _userRepository.Save();
         return(Session["LoggedUserRole"].Equals("Admin") ? RedirectToAction("Index") : RedirectToAction("UserManager", "User", new { id = Session["LoggedUserId"] }));
     }
     ViewBag.PossibleRole = _roleRepository.All;
     return(View());
 }
Пример #3
0
        public bool FindUser(string nickname, string password)
        {
            IEnumerable <User> iEnumerable = _userRepository.All;

            foreach (var user in iEnumerable.Where(user => user.NickName == nickname && user.Password == password))
            {
                _currentUser = user;
                return(true);
            }
            return(false);
        }
Пример #4
0
 public ActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         _userRepository.InsertOrUpdate(user);
         _userRepository.Save();
         return(RedirectToAction("Index"));
     }
     ViewBag.PossibleRole = _roleRepository.All;
     return(View());
 }
Пример #5
0
        public ActionResult FindOneFriend(User name)
        {
            IEnumerable <User> iEnumerable = _userRepository.All;

            _friendList = new List <User>();
            foreach (var user in iEnumerable.Where(user => user.NickName.Equals(name.NickName) || user.FirstName.Equals(name.NickName) || user.LastName.Equals(name.NickName)))
            {
                _friendList.Add(user);
            }
            return(RedirectToAction("FindFriend", "User"));
        }