Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //  var siteToUpdate = await _context.FavoriteWebSites.FindAsync(id);

            _context.Attach(FavoriteWebSites).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FavoriteWebSitesExists(FavoriteWebSites.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Cart).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CartExists(Cart.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (UserBeef.Quantity > 0)
            {
                var newProduct = new Cart()
                {
                    DateCreated   = DateTime.Now,
                    OwnerID       = User.Identity.Name,
                    Price         = (UserBeef.Price * UserBeef.Quantity),
                    ItemsInToCart = UserBeef.Quantity,
                    ProductID     = UserBeef.ProductID
                };

                _context.Carts.Add(newProduct);
            }

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Carts.Add(Cart);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            FavoriteWebSites.OwnerID = User.Identity.Name;
            _context.FavoriteWebSites.Add(FavoriteWebSites);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PlayerData = await _context.PlayerData.FindAsync(id);

            if (PlayerData != null)
            {
                _context.PlayerData.Remove(PlayerData);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            BeefObject = await _context.Beef.FindAsync(id);

            if (BeefObject != null)
            {
                _context.Beef.Remove(BeefObject);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FavoriteWebSites = await _context.FavoriteWebSites.FindAsync(id);

            if (FavoriteWebSites != null)
            {
                _context.FavoriteWebSites.Remove(FavoriteWebSites);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync(int playGame)
        {
            Console.WriteLine("Adding {0} Some thing{1}", 12, 15);
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //var newProduct = new Cart()
            //{
            //    DateCreated = DateTime.Now,
            //    OwnerID = User.Identity.Name,
            //    Price = playGame,
            //    ItemsInToCart = 1
            //};

            //_context.Carts.Add(newProduct);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }