示例#1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

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

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

            var emptyDog = new Dog();

            if (await TryUpdateModelAsync <Dog>(
                    emptyDog,
                    "dog",
                    s => s.RegisteredName,
                    s => s.CallName,
                    s => s.Sex,
                    s => s.DateOfBirth,
                    s => s.RegistrationNumber,
                    s => s.Breed,
                    s => s.OwnerID))
            {
                _context.Dogs.Add(emptyDog);
                await _context.SaveChangesAsync();

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

            PopulatePersonNamesDropDownList(_context, emptyDog.Owner);
            return(Page());
        }
示例#3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Stakes.Add(Stake);
            await _context.SaveChangesAsync();

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

            Person = await _context.People.FindAsync(id);

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

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

            Club = await _context.Clubs.FindAsync(id);

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

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