Exemple #1
0
        public async Task <IActionResult> SelectCinema(CancellationToken token)
        {
            if (!Request.Query.ContainsKey("cinemaId"))
            {
                return(await All(token));
            }

            Request.Query.TryGetValue("cinemaId", out var cinemaId);

            var user = await _userManager.FindByIdAsync(_userManager.GetUserId(User)) as IdentityUser;

            var userSession = await _userSessionRepository.FindByUserIdAsync(Guid.Parse(user.Id), token);

            userSession.CurrentCinemaId = long.Parse(cinemaId);
            await _userSessionRepository.UpdateAsync(userSession, CancellationToken.None);

            return(RedirectToAction(nameof(Edit), "Cinema"));
        }
Exemple #2
0
        public async Task <IActionResult> SelectCompany(PersonalAreaViewModel model)
        {
            if (!Request.Query.ContainsKey("companyId"))
            {
                return(await Index());
            }

            Request.Query.TryGetValue("companyId", out var companyId);

            var user = await _userManager.FindByIdAsync(_userManager.GetUserId(User)) as IdentityUser;

            var userSession = new UserSession
            {
                UserId           = Guid.Parse(user.Id),
                CurrentCompanyId = long.Parse(companyId)
            };

            await _userSessionRepository.UpdateAsync(userSession, CancellationToken.None);

            return(RedirectToAction(nameof(CompanyController.Index), "Company"));
        }