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

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

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

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Blog = await _context.Blog.FirstOrDefaultAsync(m => m.ID == id);

            Blog.Hits += 1;
            _context.Attach(Blog).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            if (Blog == null)
            {
                return(NotFound());
            }
            return(Page());
        }