public ActionResult Login(LoginViewModel model)
        {
            HomeViewModel viewModelContainer = new HomeViewModel();
            viewModelContainer.LoginViewModel = model;

            ValidateLoginViewModel(model);
            if (model.ErrorList.Count == 0)
            {
                if (!_userService.UserExists(model.Email))
                {
                    model.ErrorList.Add("W systemie nie ma użytkownika o podanym adresie E-mail.");
                    return View("~/Views/Home/Index.cshtml", viewModelContainer);
                }

                if (!_userService.UserAuthorized(model.Email, model.Password))
                {
                    model.ErrorList.Add("Podaj prawdziwe hasło dostępu do serwisu.");
                    return View("~/Views/Home/Index.cshtml", viewModelContainer);
                }
                Session.Add("CurrentUserId", _userService.GetServiceUserId(model.Email));

                return RedirectToAction("LoginRedirect");
            }
            return View("~/Views/Home/Index.cshtml", viewModelContainer);
        }
        public  ActionResult RetriveInfo()
        {
            HomeViewModel responseModel = new HomeViewModel();
            if (TempData["ResponseViewModel"] != null)
            {
                responseModel.LoginViewModel = (LoginViewModel) TempData["ResponseViewModel"];
            }

            return View("~/Views/LoggedIn/Processed.cshtml", responseModel);
        }
        public ActionResult GroupCreatedRedirect()
        {
            HomeViewModel model = new HomeViewModel();
            var responseModel = TempData["ResponseViewModel"];
            if (responseModel != null)
            {
                model.LoginViewModel = (LoginViewModel)responseModel;
            }

            return View("~/Views/LoggedIn/Processed.cshtml", model);
        }
 public HomeController()
 {
     _viewModelContainer = new HomeViewModel();
 }
        public ActionResult UpdateGroup(int groupId, string groupName, string groupDescription)
        {
            if (groupName.IsEmpty())
            {
                HomeViewModel model = new HomeViewModel();
                model.LoginViewModel.ErrorList.Add(WebResponseCode.YouAreTheAdmin);
                return View("~/Views/LoggedIn/Index.cshtml", model);
            }
            _groupService.UpdateGroup(groupName, groupDescription, groupId);
            _groupService.Commit();

            return RedirectToAction("GroupDetails", new {groupId});
        }
        public ActionResult RemoveUserFromGroup(int userId, int groupId)
        {
            var group = _groupService.GetGroupById(groupId);
            if (group.AdminId == userId)
            {
                HomeViewModel model = new HomeViewModel();
                model.LoginViewModel.ErrorList.Add(WebResponseCode.YouAreTheAdmin);
                return View("~/Views/LoggedIn/Index.cshtml", model);
            }

            _groupService.RemoveUserFromGroup(userId, groupId);
            _groupService.Commit();
            return RedirectToAction("AddUsers", new{groupId});
        }
 public ActionResult SessionExpired()
 {
     HomeViewModel viewModel = new HomeViewModel();
     viewModel.LoginViewModel.ErrorList.Add(WebResponseCode.SessionExpired);
     return View("~/Views/Home/Index.cshtml", viewModel);
 }
        public ActionResult Register(RegisterViewModel model)
        {
            HomeViewModel viewModelContainer = new HomeViewModel();
            viewModelContainer.RegisterViewModel = model;

            ValidateRegisterViewModel(model);
            if (model.ErrorList.Count == 0)
            {

                if (_userService.UserExists(model.Email))
                {
                    model.ErrorList.Add("UserExistsInDatabase", "Użytkownik o podanym adresie E-mail jest już zarejestrowany w systemie.");
                    return View("~/Views/Home/Index.cshtml", viewModelContainer);
                }

                _userService.AddUser(model.Email, model.Password);
                Session.Add("CurrentUserId", _userService.GetServiceUserId(model.Email));

                return RedirectToAction("RegisterRedirect");
            }
            viewModelContainer.ErrorAnchor = "register";
            return View("~/Views/Home/Index.cshtml", viewModelContainer);
        }