public static PTMessage AddMessage(PTMessage message, byte[] imageData) { try { // add the message to the db, set message.ID, and return the message //TODO: default return values //TODO: handle video... using (PTLinkDatabaseDataContext db = new PTLinkDatabaseDataContext()) { Message dbMessage = new Message(); dbMessage.ContentTypeId = (from c in db.ContentTypes where c.Name == message.type select c.Id).SingleOrDefault(); dbMessage.ExerciseId = message.exerciseID; dbMessage.PersonId = message.senderID; dbMessage.ProtocolId = message.protocolID; dbMessage.Timestamp = (long)message.timestamp; if (imageData != null) { //TODO: handle images and video and such dbMessage.Value = message.imageName; } else { dbMessage.Value = message.text; } db.Messages.InsertOnSubmit(dbMessage); db.SubmitChanges(); message.ID = dbMessage.Id; } return message; } catch { return null; } }
private void detach_Messages(Message entity) { this.SendPropertyChanging(); entity.ContentType = null; }
partial void UpdateMessage(Message instance);
partial void DeleteMessage(Message instance);
partial void InsertMessage(Message instance);
private void detach_Messages(Message entity) { this.SendPropertyChanging(); entity.Protocol = null; }
private void attach_Messages(Message entity) { this.SendPropertyChanging(); entity.Protocol = this; }
private void detach_Messages(Message entity) { this.SendPropertyChanging(); entity.Exercise = null; }
private void attach_Messages(Message entity) { this.SendPropertyChanging(); entity.Exercise = this; }