public static bool message_InsertMessage(int id_usr, string msg_body, int msg_type, int[] dest_users) { long id_message = 0; try { using (MessDataContext db = new MessDataContext()) { MESSAGE msg = new MESSAGE(); msg.MSG_TYPE = msg_type; msg.MSG_BODY = msg_body; msg.C_DATE = DateTime.Now; db.MESSAGEs.InsertOnSubmit(msg); db.SubmitChanges(); id_message = db.MESSAGEs.Max(i => i.ID_MESSAGE); foreach (var du in dest_users) { MESSTOUSR m2u = new MESSTOUSR(); m2u.MSG_STATE = (int)MsgState.New; m2u.ID_MESSAGE = id_message; m2u.ID_SENDER = id_usr; m2u.ID_USR = du; db.MESSTOUSRs.InsertOnSubmit(m2u); } db.SubmitChanges(); } return true; } catch (Exception) { return false; } }
private void attach_MESSTOUSRs(MESSTOUSR entity) { this.SendPropertyChanging(); entity.MESSAGE = this; }
private void detach_MESSTOUSRs(MESSTOUSR entity) { this.SendPropertyChanging(); entity.MESSAGE = null; }
partial void DeleteMESSTOUSR(MESSTOUSR instance);
partial void UpdateMESSTOUSR(MESSTOUSR instance);
partial void InsertMESSTOUSR(MESSTOUSR instance);
private void detach_MESSTOUSRs1(MESSTOUSR entity) { this.SendPropertyChanging(); entity.USER1 = null; }
private void attach_MESSTOUSRs1(MESSTOUSR entity) { this.SendPropertyChanging(); entity.USER1 = this; }