예제 #1
0
        private async Task <Company> GetCompany(CancellationToken token)
        {
            var user = await _userManager.FindByIdAsync(_userManager.GetUserId(User)) as IdentityUser;

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

            return(await _companyRepository.FindByIdAsync(userSession.CurrentCompanyId, token));
        }
예제 #2
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"));
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            //you can do the access rights checking here by using session, user, and/or filter parameter
            var sidebars = new List <SidebarMenu>();

            //if (((ClaimsPrincipal)User).GetUserProperty("AccessProfile").Contains("VES_008, Payroll"))
            //{
            //}

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

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

            var company = await _companyRepository.FindByIdAsync(userSession.CurrentCompanyId, CancellationToken.None);

            if (User.IsInRole("Administrators"))
            {
                sidebars.Add(ModuleHelper.AddTree(company.Name, "fa fa-id-card"));
                sidebars.Last().TreeChild = new List <SidebarMenu>
                {
                    ModuleHelper.AddModule(ModuleHelper.Module.Info),
                    ModuleHelper.AddModule(ModuleHelper.Module.EditInfo),
                    ModuleHelper.AddModule(ModuleHelper.Module.EditDesign)
                };

                sidebars.Add(ModuleHelper.AddTree("Cinemas", "fa fa-building"));
                sidebars.Last().TreeChild = new List <SidebarMenu>
                {
                    ModuleHelper.AddModule(ModuleHelper.Module.CinemasManagement),
                    ModuleHelper.AddModule(ModuleHelper.Module.CinemaCreate)
                };

                sidebars.Add(ModuleHelper.AddTree("Halls", "fa fa-braille"));
                sidebars.Last().TreeChild = new List <SidebarMenu>
                {
                    ModuleHelper.AddModule(ModuleHelper.Module.HallsManagement),
                    ModuleHelper.AddModule(ModuleHelper.Module.HallCreate)
                };

                sidebars.Add(ModuleHelper.AddTree("Films", "fa fa-film"));
                sidebars.Last().TreeChild = new List <SidebarMenu>
                {
                    ModuleHelper.AddModule(ModuleHelper.Module.FilmsManagement),
                    ModuleHelper.AddModule(ModuleHelper.Module.FilmCreate)
                };

                sidebars.Add(ModuleHelper.AddTree("Film sessions", "fa fa-calendar"));
                sidebars.Last().TreeChild = new List <SidebarMenu>
                {
                    ModuleHelper.AddModule(ModuleHelper.Module.FilmSessionsManagement),
                    ModuleHelper.AddModule(ModuleHelper.Module.FilmSessionCreate)
                };

                sidebars.Add(ModuleHelper.AddTree("Users", "fa fa-users"));
                sidebars.Last().TreeChild = new List <SidebarMenu>
                {
                    ModuleHelper.AddModule(ModuleHelper.Module.SuperAdmin),
                    ModuleHelper.AddModule(ModuleHelper.Module.Role),
                };
            }
            else
            {
                sidebars.Add(ModuleHelper.AddModule(ModuleHelper.Module.Info, null, company.Name));
                sidebars.Add(ModuleHelper.AddModule(ModuleHelper.Module.CinemasManagement, null, "Cinemas"));
                sidebars.Add(ModuleHelper.AddModule(ModuleHelper.Module.HallsManagement, null, "Halls"));
                sidebars.Add(ModuleHelper.AddModule(ModuleHelper.Module.FilmsManagement, null, "Films"));
                sidebars.Add(ModuleHelper.AddModule(ModuleHelper.Module.FilmSessionsManagement, null, "Film sessions"));
            }

            if (User.IsInRole("TicketControllers"))
            {
                sidebars.Add(ModuleHelper.AddModule(ModuleHelper.Module.TicketControl));
            }

            return(View(sidebars));
        }