예제 #1
0
        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();
        }
예제 #2
0
 // GET: Account
 public ActionResult Index()
 {
     using (StoreGameContext db = new StoreGameContext())
     {
         return(View(db.UsersAccounts.ToList()));
     }
 }
예제 #3
0
 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());
 }
예제 #4
0
 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());
 }
예제 #5
0
        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;
 }
예제 #8
0
 public EditModel(StoreGameContext context)
 {
     _context = context;
 }
예제 #9
0
 public IndexModel(StoreGameContext context, ILogger <IndexModel> logger)
 {
     _context = context;
     _logger  = logger;
 }
예제 #10
0
 public DetailsModel(StoreGameContext context, ILogger <DetailsModel> logger)
 {
     _context = context;
     _logger  = logger;
 }
예제 #11
0
 public IndexModel(StoreGameContext context)
 {
     _context = context;
 }
예제 #12
0
 public DetailsModel(StoreGameContext context)
 {
     _context = context;
 }
예제 #13
0
 public GamesController(StoreGameContext context)
 {
     _context = context;
 }