public bool UpdateNote_Comment(Note_CommentItem model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Note_Comments .Single(e => e.NoteId == model.NoteId && e.CommentId == model.CommentId); entity.CommentId = model.CommentId; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(Note_CommentItem note_comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateNote_CommentService(); if (!service.UpdateNote_Comment(note_comment)) { return(InternalServerError()); } return(Ok()); }
public bool CreateComment(Note_CommentItem model) { var entity = new Note_Comment() { CommentId = model.CommentId, NoteId = model.NoteId }; using (var ctx = new ApplicationDbContext()) { ctx.Note_Comments.Add(entity); return(ctx.SaveChanges() == 1); } }