Пример #1
0
        //public async Task<IActionResult> Create([Bind("Id,Name,Price,Promotion,Description,PG")] Game game)
        public async Task <IActionResult> Create(CreateGameViewModel vm)
        {
            //Category category = _context.Categories.Find(vm.IdCategory);
            //Studio studio = _context.Studios.Find(vm.IdStudio);

            var game = new Game
            {
                Name        = vm.Game.Name,
                CategoryId  = vm.Game.CategoryId,
                StudioId    = vm.Game.StudioId,
                Price       = vm.Game.Price,
                Promotion   = vm.Game.Promotion,
                Description = vm.Game.Description,
                PG          = vm.Game.PG,
            };

            //if (ModelState.IsValid)
            //{
            _context.Add(game);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
            //}
            //return View(vm);
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("ID,Name,Price")] Consoles consoles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(consoles);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(consoles));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("ID,name,game,rating,review")] UserReview userReview)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userReview);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(userReview));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("Id,TotalPrice")] ShoppingCart shoppingCart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shoppingCart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shoppingCart));
        }
Пример #6
0
        public async Task <IActionResult> Create([Bind("Id,Image,Name,DateOfRelease,Price,Quantity,Genre,Description,Trailer,Consoles")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price,Console")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(game));
        }
Пример #8
0
        public async Task <IActionResult> Register([Bind("Id,Email,Password")] User user)
        {
            if (ModelState.IsValid)
            {
                var q = _context.User.FirstOrDefault(u => u.Email == user.Email);

                if (q == null)
                {
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    var u = _context.User.FirstOrDefault(u => u.Email == user.Email && u.Password == user.Password);

                    Signin(u);

                    return(RedirectToAction("Home", "ConsolePages"));
                }
                else
                {
                    ViewData["Error"] = "Unable to comply; cannot register this user.";
                }
            }
            return(View(user));
        }