// GET: VacationRequests
        public async Task <ViewResult> Index()
        {
            var applicationDbContext = _context.VacationRequest.Include(v => v.User).Where(v => v.Deleted == false).AsQueryable();

            if (!(await usermanager.IsInRoleAsync(await usermanager.GetUserAsync(User), "الادارة")))
            {
                var userid = usermanager.GetUserId(User);
                applicationDbContext = applicationDbContext.Where(c => c.UserID == userid);
            }
            return(View(applicationDbContext));
        }
Beispiel #2
0
        protected override async Task <IEnumerable <Reserva> > GetAll()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            var id = currentUser.Id;
            // se admin não passar o id
            var isAdmin = currentUser != null && await _userManager.IsInRoleAsync(currentUser, Constants.AdministratorRole);

            if (isAdmin)
            {
                id = string.Empty;
            }

            return(await Service.GetAllByUserIdAsync(id));
        }
Beispiel #3
0
        public async Task <IActionResult> OnPostDeleteUserFromRoleAsync(string UtenteIdDel, string RuoloIdDel)
        {
            Utenti utente = _db.Utenti.Where(u => u.Id.Equals(UtenteIdDel, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();

            Models.Ruoli ruoli = _db.Ruoli.Where(r => r.Id.Equals(RuoloIdDel, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
            if (await _userManager.IsInRoleAsync(utente, ruoli.Name))
            {
                await _userManager.RemoveFromRoleAsync(utente, ruoli.Name);

                TempMessageDel = "Role removed from this user successfully !";
            }
            else
            {
                TempMessageDel = "This user doesn't belong to selected role.";
            }

            return(Page());
        }