Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Url")] tbBlog tbBlog)
        {
            if (id != tbBlog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbBlog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tbBlogExists(tbBlog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbBlog));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Url")] tbBlog tbBlog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tbBlog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbBlog));
        }