Ejemplo n.º 1
0
 public async Task OnGet([FromServices] IdentityWebContext identity)
 {
     Items = await identity.Items
             .Include(e => e.Barangay)
             .AsNoTracking()
             .ToListAsync();
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnGet([FromServices] IdentityWebContext dbContext, string id)
        {
            Id = id;

            if (!string.IsNullOrWhiteSpace(id))
            {
                var data = await dbContext.Items.FirstOrDefaultAsync(e => e.ItemId == id);

                if (data == null)
                {
                    return(NotFound("Item not found."));
                }

                //  get allowed barangays for current User
                var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

                var barangays = await dbContext.BarangayUserRoles.Where(e => e.UserId == userId).Select(e => e.BarangayId).ToListAsync();

                if (!barangays.Contains(data.BarangayId))
                {
                    return(RedirectToPage("/NotAuthorizedToEditDevice"));
                }
            }

            return(Page());
        }
Ejemplo n.º 3
0
        public ItemController(IdentityWebContext dbContext, IOptions <ApiBehaviorOptions> apiBehaviorOptions)
            : base(apiBehaviorOptions)

        {
            _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
        }