public async Task <IActionResult> LoginUser(LoginViewModel loginUser)
        {
            if (!ModelState.IsValid)
            {
                foreach (var err in ModelState.Values.SelectMany(c => c.Errors))
                {
                    ViewData["signinError"] = err.ErrorMessage;
                }
                return(View("Signin"));
            }
            var user = await _userService.GetByLogin(loginUser.Login);

            if (user == null)
            {
                ViewData["signinError"] = "You didn't sign up";
                return(View("Signin"));
            }
            if (user.Password != loginUser.Password)
            {
                ViewData["signinError"] = "Wrong password";
                return(View("Signin"));
            }

            if (loginUser.RememberUser)
            {
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
                                              AuthentificationService.CreatePrincipal(user));
            }
            return(RedirectToAction("Index", "Home"));
        }
        public async Task <IActionResult> RegisterUser(RegistrationViewModel registrationUser)
        {
            if (!ModelState.IsValid)
            {
                foreach (var err in ModelState.Values.SelectMany(c => c.Errors))
                {
                    ViewData["signupError"] = err.ErrorMessage;
                }
                return(View("Signup"));
            }
            var user = _mapper.Map <HousingUser>(registrationUser);

            if (await _userService.HasEntity(user))
            {
                ViewData["signupError"] = "User with such login already exists";
                return(View("Signup"));
            }
            user = await _userService.Create(user);

            if (user != null)
            {
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
                                              AuthentificationService.CreatePrincipal(user));
            }
            return(RedirectToAction("Index", "Home"));
        }