Exemple #1
0
        public static void Initialize(GamesContext context)
        {
            context.Database.EnsureCreated();

            // Check for any existing games
            if (context.Games.Any())
            {
                return;   // DB has been seeded
            }

            // Define test data to initialize database with
            var games = new Game[]
            {
                new Game {
                    Title = "Shadow of the Colossus", Genre = "Action-Adventure", Developer = "Team ICO", ReleaseDate = DateTime.Parse("2005-10-18"), Platform = "PS3"
                },
                new Game {
                    Title = "Fallout New Vegas", Genre = "RPG", Developer = "Obsidian Entertainment", ReleaseDate = DateTime.Parse("2010-10-19"), Platform = "PS3, Xbox360, PC"
                },
                new Game {
                    Title = "Overwatch", Genre = "FPS", Developer = "Blizzard Entertainment", ReleaseDate = DateTime.Parse("2016-5-24"), Platform = "PS4, Xbox One, PC"
                }
            };

            foreach (Game g in games)
            {
                context.Games.Add(g);
            }
            context.SaveChanges();
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            GamesContext dbContext)
        {
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseStaticFiles();
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Games API");
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // ===== Use Authentication ======
            app.UseAuthentication();
            app.UseMvc();
        }
Exemple #3
0
        public void ContextBuildsAViewModelWithAllGames()
        {
            var game = new Game {
                Name = "Game 1"
            };
            var gameViewModel = new GameViewModel {
                Name = "Game 1"
            };
            var games = new List <Game> {
                game
            };
            var mockGameRepository = new MockGameRepository().StubGetAllToReturn(games);
            var mockGameMapper     = new MockGameMapper().StubMapToReturn(gameViewModel);
            var gamesContext       = new GamesContext(mockGameRepository, mockGameMapper);

            var viewModel = gamesContext.BuildViewModel();

            Assert.NotNull(viewModel);
            Assert.IsType <GamesViewModel>(viewModel);
            Assert.Equal(games.Count, viewModel.Games.Count());

            var gameViewModels = viewModel.Games.ToList();

            Assert.Equal(game.Id, gameViewModels.First()
                         .Id);
            Assert.Equal(game.Name, gameViewModels.First()
                         .Name);
            Assert.Equal(game.Description, gameViewModels.First()
                         .Description);

            mockGameRepository.VerifyGetAllCalled();
            mockGameMapper.VerifyMapCalledWith(game);
        }
Exemple #4
0
 public GamesController(GamesContext context,
                        GamesInstanceService gamesInstanceService,
                        TeamService teamService)
 {
     _context = context;
     _gamesInstanceService = gamesInstanceService;
     _teamService          = teamService;
 }
Exemple #5
0
        public void CreatesAGamesContext()
        {
            var mockGameRepository = new MockGameRepository();
            var mockGameMapper     = new MockGameMapper();
            var gamesContext       = new GamesContext(mockGameRepository, mockGameMapper);

            Assert.NotNull(gamesContext);
        }
Exemple #6
0
        protected TestFixtureBase()
        {
            Context = GamesContextFactory.Create();

            var configProvider = new MapperConfiguration(cfg => { cfg.AddProfile <GamesProfile>(); });

            Mapper = configProvider.CreateMapper();
        }
        public static void Initialize(GamesContext context)
        {
            context.Database.EnsureCreated();

            if (!context.Games.Any())
            {
                context.Games.AddRange(GetGames());
                context.SaveChanges();
            }
        }
Exemple #8
0
        public void ContextBuildsAViewModel()
        {
            var mockGameRepository = new MockGameRepository();
            var mockGameMapper     = new MockGameMapper();
            var gamesContext       = new GamesContext(mockGameRepository, mockGameMapper);

            var viewModel = gamesContext.BuildViewModel();

            Assert.NotNull(viewModel);
            Assert.IsType <GamesViewModel>(viewModel);
        }
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IConfiguration configuration,
     GamesContext context
     )
 {
     _context       = context;
     _userManager   = userManager;
     _signInManager = signInManager;
     _configuration = configuration;
 }
Exemple #10
0
        public void ContextRemovesAGame()
        {
            var game = new Game {
                Name = "Game 2"
            };
            var mockGameRepository = new MockGameRepository().StubGetByToReturn(game);
            var mockGameMapper     = new MockGameMapper();
            var gamesContext       = new GamesContext(mockGameRepository, mockGameMapper);

            gamesContext.Remove(game.Id);

            mockGameRepository.VerifyGetByCalledWith(game.Id);
            mockGameRepository.VerifyRemoveCalledWith(game);
        }
        public ActionResult Analyze(string someTitle, int DeveloperId, DateTime ReleaseDate, string Genre, string Rating)
        {
            GamesContext haberdashery = new GamesContext();
            Game         gamegame     = new Game();

            gamegame.Title       = someTitle;
            gamegame.ReleaseDate = ReleaseDate;
            gamegame.Rating      = Rating;
            gamegame.Genre       = Genre;
            gamegame.Developer   = haberdashery.Developers.Find(DeveloperId);
            haberdashery.Games.Add(gamegame);
            haberdashery.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public static GamesContext Create()
        {
            var options = new DbContextOptionsBuilder <GamesContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new GamesContext(options);

            context.Database.EnsureCreated();

            context.Games.AddRange(new GamesFactory().Games);

            context.SaveChanges();

            return(context);
        }
        public static void Initialize(GamesContext context)
        {
            context.Database.EnsureCreated();

            /*
             *  context.Games.Any() werkt niet ?
             */
            // if (!context.Games.Any())
            // {

            //     var pb1 = new Publisher()
            //     {
            //         PublisherName = "Epic Games"
            //     };
            //     var pb2 = new Publisher()
            //     {
            //         PublisherName = "Bungie"
            //     };
            //     var pb3 = new Publisher()
            //     {
            //         PublisherName = "Valve"
            //     };

            //     var g1 = new Game() {
            //         Title = "Gears of War",
            //         Publisher = pb1
            //     };
            //     var g2 = new Game() {
            //         Title = "Halo",
            //         Publisher = pb2
            //     };
            //     var g3 = new Game() {
            //         Title = "Half-Life",
            //         Publisher = pb3
            //     };

            //     context.Publishers.Add(pb1);
            //     context.Publishers.Add(pb2);
            //     context.Publishers.Add(pb3);

            //     context.Games.Add(g1);
            //     context.Games.Add(g2);
            //     context.Games.Add(g3);

            //     context.SaveChanges();
            // }
        }
Exemple #14
0
        public static List <Entrega> ListarEntrega()
        {
            var lista = new List <Entrega>();

            using (var db = new GamesContext())
            {
                lista = db.Entregas
                        .OrderBy(x => x.DataEntrega)
                        .ToList()
                        .Select(x => new Entrega()
                {
                    NumeroEntrega      = x.NumeroEntrega,
                    DataEntrega        = x.DataEntrega,
                    QuantidadeEntregue = x.QuantidadeEntregue,
                    IdFornecedor       = x.IdFornecedor
                }).ToList();
            }

            return(lista);
        }
Exemple #15
0
        public static List <Estoque> ListarEstoque()
        {
            var lista = new List <Estoque>();

            using (var db = new GamesContext())
            {
                lista = db.Estoques
                        .OrderBy(x => x.Id)
                        .ToList()
                        .Select(x => new Estoque()
                {
                    QuantidadeTotal      = x.QuantidadeTotal,
                    QuantidadeDisponivel = x.QuantidadeDisponivel,
                    IdJogo = x.IdJogo,
                    Jogo   = x.Jogo
                }).ToList();
            }

            return(lista);
        }
Exemple #16
0
 public GamesController(GamesContext context)
 {
     _context = context;
     if (_context.GamesItems.Count() == 0)
     {
         _context.GamesItems.Add(new GamesItem {
             Name = "Cod"
         });
         _context.GamesItems.Add(new GamesItem {
             Name = "PES"
         });
         _context.GamesItems.Add(new GamesItem {
             Name = "Fifa"
         });
         _context.GamesItems.Add(new GamesItem {
             Name = "Winning eleveng"
         });
         _context.SaveChanges();
     }
 }
Exemple #17
0
        public static List <Funcionario> ListarFuncionarios()
        {
            var lista = new List <Funcionario>();

            using (var db = new GamesContext())
            {
                lista = db.Funcionarios
                        .OrderBy(x => x.Nome)
                        .ToList()
                        .Select(x => new Funcionario()
                {
                    Nome      = x.Nome,
                    Telefone  = x.Telefone,
                    Salario   = x.Salario,
                    IsAtivo   = x.IsAtivo,
                    IsGerente = x.IsGerente
                }).ToList();
            }

            return(lista);
        }
Exemple #18
0
 //Now have your Seed method be static, and it will be responsible for creating sample data for your database.
 //upon the start of your server.
 //THe seed method will take our context class as a argument, therefore enabling use to create data and save data to our context.
 public static void Seed(GamesContext context)
 {
     //We will only seed data if our table doesn't have data.
     //If the first value of the database that contains a id is null
     if (context.Games.FirstOrDefault() == null)
     {
         //We will assign a new game
         Game newGame1 = new Game(
             title: "Call of Duty Modern Warfare",
             genre: "First Person Shooter",
             releaseYear: 2007,
             company: "Activision"
             );
         //Now add all your game and save it to your database.
         context.Games.Add(newGame1);
         context.SaveChanges();
         //We will assign a new game
         Game newGame2 = new Game(
             title: "Gears of War 1",
             genre: "Third Person Shooter",
             releaseYear: 2006,
             company: "Epic Games"
             );
         //Now add all your game and save it to your database.
         context.Games.Add(newGame2);
         context.SaveChanges();
         //We will assign a new game
         Game newGame3 = new Game(
             title: "Fortnite",
             genre: "Survival",
             releaseYear: 2017,
             company: "Epic Games"
             );
         //Now add all your game and save it to your database.
         context.Games.Add(newGame3);
         context.SaveChanges();
     }
     //Then have a empty return.
     return;
 }
Exemple #19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, GamesContext context)
        {
            EnsureGamesData.Seed(context);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseCors(builder =>
            {
                //Have your CorsPolicyBuilder builder returned when your IApplicationBuilder instance uses cors have it use AnyHeader, AnyMethod, AnyOrigin, and AnyCredentials.
                builder.AllowAnyHeader()
                .AllowAnyMethod()
                .AllowAnyOrigin();
            });
            app.UseMvc();
        }
        public static void Destroy(GamesContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }
 public EFCreatePostCommand(GamesContext context) : base(context)
 {
 }
Exemple #22
0
 public HomeController(ILogger <HomeController> logger, GamesContext context)
 {
     _logger  = logger;
     _context = context;
 }
 public EFCreateCommentCommand(GamesContext context, IEmailSender s) : base(context)
 {
     _emailSender = s;
 }
 public GenderRepository(GamesContext gamesContext)
 {
     _context = gamesContext;
 }
Exemple #25
0
 public GamesController(GamesContext context)
 {
     this.context = context;
 }
Exemple #26
0
 public GamesController(GamesContext context)
 {
     _context = context;
 }
Exemple #27
0
 public HighScoreOrchestrator()
 {
     _gamesContext = new GamesContext();
 }
Exemple #28
0
 public GamesAPI(GamesContext context)
 {
     _context = context;
 }
 public CreateGameUsingNewTitleHandler(GamesContext dataStore, IMediator mediator)
 {
     _dataStore = dataStore;
     _mediator  = mediator;
 }
 public SetCoverArtForGameHandler(GamesContext dataStore, IMediator mediator, IConfiguration configuration)
 {
     _dataStore = dataStore;
     _mediator  = mediator;
     _scheme    = configuration["coverArt:scheme"];
 }