Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Message,Author,TimeStamp")] Hello hello)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hello);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hello));
        }
Exemplo n.º 2
0
 public async Task <ActionResult> Post([FromBody] Hello value)
 {
     if (ModelState.IsValid)
     {
         _context.Hello.Add(value);
         await _context.SaveChangesAsync();
     }
     return(Created(new Uri(Request.Path + "/" + (_context.Hello.Last().ID).ToString(), UriKind.Relative), value));
 }