public int InsertSave(IncidentNoteData data) { int _return = 0; IncidentNote _incidentNote = Insert(data); _niEntities.SaveChanges(); _return = 1; return(_return); }
// // Insert one row into IncidentNotes // public IncidentNote Insert(IncidentNoteData data) { IncidentNote _incidentNote = new IncidentNote(); _incidentNote.NoteTypeId = data.NoteTypeId; _incidentNote.Note = data.Note; _niEntities.IncidentNotes.Add(_incidentNote); return(_incidentNote); }
// /// <summary> /// Extension method... /// can be called fluently by the class or as a static method. /// </summary> /// <param name="incidentNote"></param> /// <returns>a populated IncidentNoteData class</returns> public static IncidentNote ToIncidentNote(this IncidentNoteData incidentNote) { return(new IncidentNote() { IncidentNoteId = incidentNote.IncidentNoteId, NoteTypeId = incidentNote.NoteTypeId, Note = incidentNote.Note, CreatedDate = incidentNote.CreatedDate }); }
public int UpdateSave(IncidentNoteData data) { int _return = Update(data); if (_return > 0) { _niEntities.SaveChanges(); } return(_return); }
// // Return one row of IncidentNotes // public IncidentNoteData GetByPrimaryKey(long incidentNotesId) { IncidentNoteData _incidentNote = null; var _incidentNotes = ListIncidentNoteQueryable() .Where(_r => _r.IncidentNoteId == incidentNotesId); if (_incidentNotes.Count() > 0) { _incidentNote = _incidentNotes.First(); } return(_incidentNote); }
// // Update one row of IncidentNotes // public int Update(IncidentNoteData data) { int _return = 0; var _incidentNotes = from _r in _niEntities.IncidentNotes where _r.IncidentNoteId == data.IncidentNoteId select _r; if (_incidentNotes.Count() > 0) { IncidentNote _incidentNote = _incidentNotes.First(); if (_incidentNote.NoteTypeId != data.NoteTypeId) { _incidentNote.NoteTypeId = data.NoteTypeId; } if (_incidentNote.Note != data.Note) { _incidentNote.Note = data.Note; } _return = 1; // one row updated } return(_return); }