public static void Initialize(IServiceProvider serviceProvider) { using var context = new StoreGameContext( serviceProvider.GetRequiredService <DbContextOptions <StoreGameContext> >() ); if (context.Game.Any()) { return; } context.Game.AddRange( new Game { Price = 5.99M, Title = "War", ReleaseDate = DateTime.Parse("1972-02-08") }, new Game { Price = 16.99M, Title = "Battleship", ReleaseDate = DateTime.Parse("1982-02-08") }, new Game { Price = 28.89M, Title = "Settlers of Catan", ReleaseDate = DateTime.Parse("2006-01-08") } ); context.SaveChanges(); }
// GET: Account public ActionResult Index() { using (StoreGameContext db = new StoreGameContext()) { return(View(db.UsersAccounts.ToList())); } }
public ActionResult Register(UserAccount account) { if (ModelState.IsValid) { using (StoreGameContext db = new StoreGameContext()) { db.UsersAccounts.Add(account); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = account.FirstName + "" + account.LastName + " Zarejestrowano."; } return(View()); }
public ActionResult Login(UserAccount user) { using (StoreGameContext db = new StoreGameContext()) { var usr = db.UsersAccounts.Where(u => u.Username == user.Username && u.Password == user.Password).FirstOrDefault(); if (usr != null) { Session["UserID"] = usr.UserID.ToString(); Session["Username"] = usr.Username.ToString(); return(RedirectToAction("LoggedIn")); } else { ModelState.AddModelError("", "Username or Password is wrong."); } } return(View()); }
public static void Initialize(IServiceProvider serviceProvider) { var context = new StoreGameContext( serviceProvider.GetRequiredService <DbContextOptions <StoreGameContext> >() ); if (context.Game.Any()) { return; } context.Game.AddRange( new Game { Price = 5.60M, Title = "Among us ", ReleaseDate = DateTime.Parse("1976-05-6") }, new Game { Price = 85.60M, Title = "Aminal Crossing ", ReleaseDate = DateTime.Parse("2009-11-6") }, new Game { Price = 55.90M, Title = "Cash ", ReleaseDate = DateTime.Parse("1976-05-6") } ); context.SaveChanges(); }
public CreateModel(StoreGameContext context) { _context = context; }
public DeleteModel(StoreGameContext context) { _context = context; }
public EditModel(StoreGameContext context) { _context = context; }
public IndexModel(StoreGameContext context, ILogger <IndexModel> logger) { _context = context; _logger = logger; }
public DetailsModel(StoreGameContext context, ILogger <DetailsModel> logger) { _context = context; _logger = logger; }
public IndexModel(StoreGameContext context) { _context = context; }
public DetailsModel(StoreGameContext context) { _context = context; }
public GamesController(StoreGameContext context) { _context = context; }