Ejemplo n.º 1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Regions       = _context.Regions.ToList();
            Museum.Region = Regions.Where(r => r.Id == SelectedRegionId).FirstOrDefault();
            _context.Attach(Museum).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MuseumExists(Museum.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToPage("./Details", new { id = Museum.Id }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Museum = await _context.Museums.FindAsync(id);

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

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