public ProductController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     ProductManager = new ProductManager(context);
     PegiManager = new PegiManager(context);
     MultimediaManager = new MultimediaManager(context);
 }
Exemple #2
0
 public IActionResult Edit(int id)
 {
     using (var db = new GameStoreDbContext())
     {
         var idOdGame = db.Games.Find(id);
         return(this.View(idOdGame));
     }
 }
Exemple #3
0
 public IActionResult Delete(int id)
 {
     using (var db = new GameStoreDbContext())
     {
         var idOfGame = db.Games.Find(id);
         return(View(idOfGame));
     }
 }
Exemple #4
0
 public void AddRange(IEnumerable <UserGame> userGames)
 {
     using (var db = new GameStoreDbContext())
     {
         db.AddRange(userGames);
         db.SaveChanges();
     }
 }
 public IActionResult Index()
 {
     using (var db = new GameStoreDbContext())
     {
         var game = db.Games.ToList();
         return(this.View(game));
     }
 }
Exemple #6
0
 public IActionResult Edit(int id)
 {
     using (var db = new GameStoreDbContext())
     {
         var gameToEdit = db.Games.Find(id);
         return(View(gameToEdit));
     }
 }
Exemple #7
0
 public IActionResult Index()
 {
     using (var db = new GameStoreDbContext())
     {
         var allGames = db.Games.ToList();
         return(View(allGames));
     }
 }
Exemple #8
0
        public bool Find(string email, string password)
        {
            string passwordHash = PasswordUtilities.GenerateHash(password);

            using (var db = new GameStoreDbContext())
            {
                return(db.Users.Any(x => x.Email == email && x.PasswordHash == passwordHash));
            }
        }
Exemple #9
0
        static StartUp()
        {
            using (GameStoreDbContext database = new GameStoreDbContext())
            {
                database.Database.Migrate();
            }

            AutoMapperConfiguration.Initialize();
        }
Exemple #10
0
 public bool IsAdmin(string email)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db
                .Users
                .Any(x => x.Email == email && x.IsAdmin == true));
     }
 }
Exemple #11
0
 public bool Find(LoginViewModel model)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db
                .Users
                .Any(x => x.Email == model.Email && x.Password == model.Password));
     }
 }
Exemple #12
0
 public IActionResult Edit(Game game)
 {
     using (var db = new GameStoreDbContext())
     {
         db.Games.Update(game);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Exemple #13
0
        public int?GetGameId(string title)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.FirstOrDefault(g => g.Title == title);

                return(game?.Id);
            }
        }
Exemple #14
0
        public DbSynchronizer(GameStoreDbContext gameStoreDbContext, NorthwindDbContext northwindDbContext)
        {
            _gameStoreDbContext = gameStoreDbContext;
            _northwindDbContext = northwindDbContext;

            InitEntitiesSynchronizers();
            InitCleaners();
            InitNavigationPropertiesSynchronizers();
        }
Exemple #15
0
        public void AddGame(int id)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.SingleOrDefault(x => x.Id == id);

                this.Games.Add(game);
            }
        }
Exemple #16
0
        public void InitializeDatabase()
        {
            Console.WriteLine("Initializing database...");

            using (var context = new GameStoreDbContext())
            {
                context.Database.Migrate();
            }
        }
        private static void ConfigureDatabase()
        {
            var dbContext = new GameStoreDbContext();

            using (dbContext)
            {
                dbContext.Database.Migrate();
            }
        }
Exemple #18
0
 public void Delete(int id)
 {
     using (var db = new GameStoreDbContext())
     {
         var game = db.Games.FirstOrDefault(g => g.Id == id);
         db.Games.Remove(game);
         db.SaveChanges();
     }
 }
Exemple #19
0
 public bool IsAdmin(string email)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db.Users
                .FirstOrDefault(u => u.Email.ToLower() == email.ToLower())
                .IsAdmin);
     }
 }
Exemple #20
0
 public void Delete(int id)
 {
     using (var db = new GameStoreDbContext())
     {
         var game = db.Games.Find(id);
         db.Games.Remove(game);
         db.SaveChanges();
     }
 }
Exemple #21
0
        public Game FindById(int id)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.Find(id);

                return(game);
            }
        }
 public bool IsExist(int id)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db
                .Games
                .Any(x => x.Id == id));
     }
 }
Exemple #23
0
 public bool UserExists(string email, string password)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db
                .Users
                .Any(u => u.Email == email && u.Password == password));
     }
 }
Exemple #24
0
        public void InitializeDatabase()
        {
            Console.WriteLine("Initializing database...");

            using (var context = new GameStoreDbContext())
            {
                context.Database.Migrate();// in EF the Migration has been automatic
            }
        }
 public bool IsAdmin(string email)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db
                .Users
                .Any(u => u.Email == email && u.IsAdmin));
     }
 }
        public Game GetGameByGivenId(int id)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.SingleOrDefault(x => x.Id == id);

                return(game);
            }
        }
Exemple #27
0
        static Launcher()
        {
            using (var context = new GameStoreDbContext())
            {
                context.Database.Migrate();
            }

            AutoMapperConfiguration.Initialize();
        }
Exemple #28
0
 public IActionResult Delete(Game game)
 {
     using (var db = new GameStoreDbContext())
     {
         db.Remove(game);
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Exemple #29
0
 public User FindByEmail(string email)
 {
     using (var db = new GameStoreDbContext())
     {
         return(db.Users
                .Include(x => x.Games)
                .ThenInclude(x => x.Game)
                .FirstOrDefault(x => x.Email == email));
     }
 }
        public void DeleteGameFromDbByGivenId(int id)
        {
            using (var db = new GameStoreDbContext())
            {
                var game = db.Games.SingleOrDefault(x => x.Id == id);

                db.Games.Remove(game);
                db.SaveChanges();
            }
        }
 public Game Find(int id)
 {
     using (GameStoreDbContext dbContext = new GameStoreDbContext())
     {
         return(dbContext
                .Games
                .Where(g => g.Id == id)
                .FirstOrDefault());
     }
 }
Exemple #32
0
 public ProductManager(GameStoreDbContext context) : base(context) { }
Exemple #33
0
 public OrderManager(GameStoreDbContext context) : base(context) { }
Exemple #34
0
 public PegiManager(GameStoreDbContext context) : base(context) { }
Exemple #35
0
 public Manager(GameStoreDbContext context)
 {
     Context = context;
 }
 public OrderController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     AccountManager = new AccountManager(context);
     OrderManager = new OrderManager(context);
 }
 public OpinionController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     OpinionManager = new OpinionManager(context);
     ProductManager = new ProductManager(context);
 }
 public AccountController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     AccountManager = new AccountManager(context);
 }
Exemple #39
0
 public PegiController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     PegiManager = new PegiManager(context);
 }
Exemple #40
0
 public OpinionManager(GameStoreDbContext context) : base(context) { }
 public ArticleController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     ArticleManager = new ArticleManager(context);
 }
Exemple #42
0
 public ArticleManager(GameStoreDbContext context) : base(context) { }
 public MultimediaManager(GameStoreDbContext context) : base(context) { }
Exemple #44
0
 public HomeController()
 {
     GameStoreDbContext context = new GameStoreDbContext();
     ProductManager = new ProductManager(context);
 }
Exemple #45
0
 public AccountManager(GameStoreDbContext context) : base(context) { }