9.0: NoteEdit Model
NoteEdit Model
NoteEdit Modelnamespace ElevenNote.Models
{
public class NoteEdit
{
public int NoteId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}
}UpdateNote Method
UpdateNote Methodpublic bool UpdateNote(NoteEdit model) { using(var ctx = new ApplicationDbContext()) { var entity = ctx .Notes .Single(e => e.NoteId == model.NoteId && e.OwnerId == _userId); } }public bool UpdateNote(NoteEdit model) { using(var ctx = new ApplicationDbContext()) { var entity = ctx .Notes .Single(e => e.NoteId == model.NoteId && e.OwnerId == _userId); entity.Title = model.Title; entity.Content = model.Content; entity.ModifiedUtc = DateTimeOffset.UtcNow; return ctx.SaveChanges() == 1; } }
Edit Method
Edit MethodLast updated