示例#1
0
        public async Task <IActionResult> Create([Bind("Id,What,Where,When,How,Why,Title")] Thing thing)
        {
            if (ModelState.IsValid)
            {
                _context.Add(thing);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(thing));
        }
示例#2
0
        public async Task <ActionResult <Thing> > CreateThing(Thing thing)
        {
            _context.Things.Add(thing);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetThing), new { id = thing.Id }, thing));
        }