Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Url,Author,ImageUrl,Description,Body,IsPublished,PublishedDate")] Blog blog)
        {
            if (id != blog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }