public async Task <SupportTicket> GetTicket(int id)
        {
            int requester_id = await base.GetUserId(httpContext.GetCurrentAuth());

            using (var _context = contextFactory.CreateDbContext())
            {
                var ticket = await _context.SupportTicket
                             .Where(x => x.Id == id)
                             .Include(x => x.TicketChat)
                             .FirstOrDefaultAsync();

                foreach (var a in ticket.TicketChat)
                {
                    if (a.CreatorId == requester_id)
                    {
                        a.IsCurrentUser = true;
                    }
                }

                if (CurrentExtensions.HasPrivileges(ticket.UserId, httpContext, contextFactory))
                {
                    return(ticket);
                }

                throw new ArgumentException("Access forbidden!");
            }
        }
示例#2
0
        public async Task <Users> GetUserInfo(int id)
        {
            using (var _context = contextFactory.CreateDbContext())
            {
                var user = await _context.Users
                           .Include(x => x.SupportTicket)
                           .Include(x => x.WishList)
                           .Include(x => x.UserKeywords)
                           .Include(x => x.UserTrips)
                           .FirstOrDefaultAsync(x => x.Id == id);

                if (CurrentExtensions.HasPrivileges(user.Id, httpContext, contextFactory))
                {
                    return(user);
                }

                throw new ArgumentException("Access forbidden!");
            }
        }