public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Beer.SwitchedForId != null && Beer.SwitchedForId != -1)
            {
                var switchedBeer = _context.Beer.Single(b => b.Id == Beer.SwitchedForId);

                switchedBeer.RemovedBy   = CreditTo;
                switchedBeer.RemovedDate = DateTime.Now;
            }
            else
            {
                Beer.SwitchedFor   = null;
                Beer.SwitchedForId = null;
            }

            Beer.AddedDate = DateTime.Now;
            Beer.CreatedBy = CreditTo;
            _context.Beer.Add(Beer);

            await _context.SaveChangesAsync();

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

            Beer.CreatedBy = User.FindFirst("name").Value;
            Beer.AddedDate = DateTime.Now;
            _context.Attach(Beer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BeerExists(Beer.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

            var beer = await _context.Beer.FindAsync(SelectedBeer);

            beer.CreatedBy = SelectedUser;
            await _context.SaveChangesAsync();

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

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

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

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

            var beer = _context.Beer.Single(b => b.Id == SelectedBeer);

            if (beer == null)
            {
                return(Page());
            }

            var user = User.FindFirst("name").Value;

            beer.RemovedDate = DateTime.Now;
            beer.RemovedBy   = user;
            beer.SwitchedFor = await _context.Beer.FirstAsync(b => b.CreatedBy == user && b.RemovedDate == null);

            await _context.SaveChangesAsync();

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