public async Task <IActionResult> Create([Bind("ID,Title,DateCreated,DateModified,Details")] NoteContext noteContext) { if (ModelState.IsValid) { _context.Add(noteContext); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(noteContext)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Username,Text,Time,Likes,Forward")] NoteDB noteDB) { if (ModelState.IsValid) { noteDB.Username = User.Identity.GetUserName(); noteDB.Likes = "无"; noteDB.Time = DateTime.Now; db.Notes.Add(noteDB); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(noteDB)); }
public async Task <IActionResult> PutNotes(int id, Note note) { note.UID = id; _context.Entry(note).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DCandidateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }