public ActionResult Details(int id) { var db = new FootballDbContext(); var tactic = db.Footballs .Include(t => t.Author) .Where(t => t.Id == id) .Select(t => new TacticsDetails { TacticName = t.TacticName, Formation = t.Formation, Description = t.Description, Image = t.Image, PlayerPosition = t.PlayerPosition, FullName = t.Author.FullName, Id = t.Id }) .FirstOrDefault(); if (tactic == null) { return(HttpNotFound()); } return(View(tactic)); }
public static void Main(string[] args) { using (FootballDbContext db = new FootballDbContext()) { SetDb(db); } }
public ActionResult Create(CreateTactics model) { if (this.ModelState.IsValid) { var authorId = this.User.Identity.GetUserId(); var tactic = new Football { TacticName = model.TacticName, Description = model.Description, Formation = model.Formation, PlayerPosition = model.PlayerPosition, Image = model.Image, AuthorId = authorId }; var db = new FootballDbContext(); db.Footballs.Add(tactic); db.SaveChanges(); return(RedirectToAction("Details", new { id = tactic.Id })); } return(View(model)); }
public Repository(FootballDbContext db) { _db = db; if (_db != null) { _dbSet = _db.Set <T>(); } }
public static IFootballManager MockFootballManager(FootballDbContext dbContext) { return(new FootballManager( MockFootballClient(), MockCompetitionRepository(dbContext), MockPlayerRepository(dbContext), MockTeamRepository(dbContext), new TracerLogManager())); }
public TestHome() { DbContextOptionsBuilder <FootballDbContext> builder = new DbContextOptionsBuilder <FootballDbContext>(); builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); DbContextOptions <FootballDbContext> options = builder.Options; _context = new FootballDbContext(options); }
public MockDbInitializer( FootballDbContext context, ILogger <MockDbInitializer> logger, IServiceProvider serviceProvider ) { _context = context; _logger = logger; _serviceProvider = serviceProvider; }
public void CreateInMemoryDatabaseTest() { using (DbConnection connection = new SQLiteConnection("data source=:memory:")) { // This is important! Else the in memory database will not work. connection.Open(); using (var context = new FootballDbContext(connection, false)) { context.Set <Team>().Add(new Team { Name = "New", Coach = new Coach { City = "New", FirstName = "New", LastName = "New", Street = "New" }, Players = new List <Player> { new Player { City = "New", FirstName = "New", LastName = "New", Street = "New", Number = 1 }, new Player { City = "New", FirstName = "New", LastName = "New", Street = "New", Number = 2 } }, Stadion = new Stadion { Name = "New", City = "New", Street = "New" } }); context.SaveChanges(); } using (var context = new FootballDbContext(connection, false)) { Assert.AreEqual(1, context.Set <Team>().Count()); } } }
public static FootballDbContext NewFootballDbContext(string databaseName = "testDB") { var options = new DbContextOptionsBuilder <FootballDbContext>() .UseInMemoryDatabase(databaseName: databaseName) .EnableSensitiveDataLogging() .Options; var context = new FootballDbContext(options); return(context); }
public ActionResult Index() { var db = new FootballDbContext(); var footballs = db.Footballs .OrderByDescending(f => f.Id) .Take(2) .Select(f => new ListTactics { Id = f.Id, TacticName = f.TacticName, Formation = f.Formation, Image = f.Image }) .ToList(); return(View(footballs)); }
public ActionResult ConfirmDelete(int id) { var db = new FootballDbContext(); var tactics = db.Footballs .Where(t => t.Id == id) .FirstOrDefault(); if (tactics == null) { return(HttpNotFound()); } db.Footballs.Remove(tactics); db.SaveChanges(); return(RedirectToAction("All", "Football")); }
public ActionResult Edit(CreateTactics models) { if (ModelState.IsValid) { using (var db = new FootballDbContext()) { var tactics = db.Footballs.Find(models.Id); tactics.Description = models.Description; tactics.Formation = models.Formation; tactics.PlayerPosition = models.PlayerPosition; tactics.TacticName = models.TacticName; tactics.Image = models.Image; db.SaveChanges(); } return(RedirectToAction("TacticsDetails", new { id = models.Id })); } return(View(models)); }
public ActionResult All(int page = 1) { var db = new FootballDbContext(); var pageSize = 5; var tactics = db.Footballs .OrderByDescending(t => t.Id) .Skip((page - 1) * pageSize) .Select(t => new ListTactics { Id = t.Id, Formation = t.Formation, Image = t.Image, TacticName = t.TacticName }) .ToList(); ViewBag.CurrentPage = page; return(View(tactics)); }
public ActionResult Delete(int id) { var db = new FootballDbContext(); var tactics = db.Footballs .Where(t => t.Id == id) .Select(t => new Delete { TacticName = t.TacticName, Formation = t.Formation, Description = t.Description, Image = t.Image, PlayerPosition = t.PlayerPosition, Id = t.Id }) .FirstOrDefault(); if (tactics == null) { return(HttpNotFound()); } return(View(tactics)); }
public PlayerRepository(FootballDbContext context) : base(context) { this.context = context; }
public AddAreasCommandHandler(FootballDbContext dbContext, IFootballDataHttpClient footballDataHttpClient) { _dbContext = dbContext; _footballDataHttpClient = footballDataHttpClient; }
public AgentsController(FootballDbContext context) { _context = context; }
public FootballDBManager(FootballDbContext footballDbContext) { this.footballDbContext = footballDbContext; }
public PlayersService(FootballDbContext context) { _context = context; }
public EfPlayerRepository(FootballDbContext dbContext) : base(dbContext) { }
public OwnersController(FootballDbContext context) { _context = context; }
public ScoutsController(FootballDbContext context) { _context = context; }
public CompetitionServiceTests() { this.context = DatabaseTools.NewFootballDbContext(DB_NAME); this.competitionService = new CompetitionService(new UnitOfWork(this.context)); }
public PlayerRepository(FootballDbContext context, IUserResolver userResolver) : base(context, userResolver) { }
public PositionsService(FootballDbContext context) { _context = context; }
public CompetitionTeamRepository(FootballDbContext context) : base(context) { }
public BaseEFRepository(FootballDbContext context, IUserResolver userResolver) { Context = context; UserResolver = userResolver; DbSet = Context.Set <T>(); }
public EntityFrameworkRepository(FootballDbContext dbContext) { DbContext = dbContext; }
public FootballRepository(FootballDbContext dbContext) { _dbContext = dbContext; }
public EfTeamRepository(FootballDbContext dbContext) { _dbContext = dbContext; }