Exemplo n.º 1
0
        /// <summary>
        /// Get a WizardUser object by id
        /// </summary>
        /// <param name="id">The id of the user to get</param>
        /// <param name="context">The context</param>
        /// <returns>WizardsUser object</returns>
        public static WizardsUser GetUser(int id, TheWizardsGameShopContext context)
        {
            var user = context.WizardsUser
                       .Where(u => u.UserId.Equals(id))
                       .FirstOrDefault();

            return(user);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get a WizardUser object by username
        /// </summary>
        /// <param name="userName">The username of the user to get</param>
        /// <param name="context">The context</param>
        /// <returns>WizardsUser object</returns>
        public static WizardsUser GetUser(string userName, TheWizardsGameShopContext context)
        {
            var user = context.WizardsUser
                       .Where(u => u.UserName.Equals(userName))
                       .FirstOrDefault();

            return(user);
        }
        public static List <Relationship> getRequestsReceived(int?id, TheWizardsGameShopContext context)
        {
            if (id == null)
            {
                return(null);
            }
            var requests = context.Relationship.Include(r => r.SenderNavigation).Where(r => r.Receiver == id && !(bool)r.IsAccepted);

            return(requests.ToList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get the currently logged in user using the id stored in session
        /// </summary>
        /// <param name="ctr"></param>
        /// <param name="context">The context</param>
        /// <returns>WizardsUser object</returns>
        public static WizardsUser GetSessionUser(Controller ctr, TheWizardsGameShopContext context)
        {
            int?sessionUserId = ctr.HttpContext.Session.GetInt32("userId");

            if (sessionUserId != null)
            {
                return(GetUser(Convert.ToInt32(sessionUserId), context));
            }

            return(null);
        }
Exemplo n.º 5
0
 public UserRolesController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public OrderDetailsController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
Exemplo n.º 7
0
 public GameCategoriesController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public ProvincesController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Check if a user with the given username exists
 /// </summary>
 /// <param name="userName">The username of the user to check</param>
 /// <returns>Whether the user exists</returns>
 public static bool UserExists(string userName, TheWizardsGameShopContext context)
 {
     return(context.WizardsUser.Any(e => e.UserName == userName));
 }
Exemplo n.º 10
0
 public FavoritePlatformsController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
Exemplo n.º 11
0
 public HomeController(ILogger <HomeController> logger, TheWizardsGameShopContext context)
 {
     _logger = logger;
 }
Exemplo n.º 12
0
 public RelationshipsController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public AddressesController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public RatingsController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
Exemplo n.º 15
0
 public GameStatusesController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public ReviewsController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
Exemplo n.º 17
0
 public GamesController(TheWizardsGameShopContext context, IWebHostEnvironment webHostEnvironment)
 {
     _context            = context;
     _webHostEnvironment = webHostEnvironment;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Check if a user with the given id exists
 /// </summary>
 /// <param name="id">The id of the user to check</param>
 /// <returns>Whether the user exists</returns>
 public static bool UserExists(int id, TheWizardsGameShopContext context)
 {
     return(context.WizardsUser.Any(e => e.UserId == id));
 }
Exemplo n.º 19
0
 public CartsController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public GendersController(TheWizardsGameShopContext context)
 {
     _context = context;
 }
 public static int countRequestsReceived(int?id, TheWizardsGameShopContext context)
 {
     return(id == null ? 0 : context.Relationship.Include(r => r.SenderNavigation).Where(r => r.Receiver == id && !(bool)r.IsAccepted).Count());
 }