public async Task <IActionResult> Edit(int id, [Bind("ID,Date,Text")] Entry entry)
        {
            if (id != entry.EntryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(entry);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EntryExists(entry.EntryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(entry));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Note> > Put(Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_db.Notes.Any(x => x.Id == note.Id))
            {
                return(NotFound());
            }

            _db.Update(note);
            await _db.SaveChangesAsync();

            return(Ok(note));
        }