Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("SageId,Name,Age,Photo,City")] Sage sage)
        {
            if (id != sage.SageId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    // if (!MovieExists(sage.SageId))
                    // {
                    //     return NotFound();
                    // }
                    // else
                    // {
                    //     throw;
                    // }
                }

                return(RedirectToAction("Index"));
            }

            return(View(sage));
        }
Esempio n. 2
0
        public async Task <ActionResult <Book> > Post(Book book)
        {
            _context.Books.Add(book);
            await _context.SaveChangesAsync();

            //return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
            return(CreatedAtAction(nameof(Get), new { id = book.BookId }, book));
        }