public override bool Load(int RowId) { CurrentConnection = new DatabaseDataContext(); var q = from x in CurrentConnection.tasks_calls where x.id.Equals(RowId) select x; CurrentRow = q.FirstOrDefault(); return true; }
/// <summary> /// Create a new binding between a task and a call /// </summary> /// <param name="TaskId">Task ID</param> /// <param name="CallId">Call ID</param> /// <returns>Insert ID of the new row</returns> public int New(int TaskId, int CallId) { // Check that there exists no identical binding using (DatabaseDataContext db = new DatabaseDataContext()) { var row = from x in db.tasks_calls where x.call_id == CallId && x.task_id == TaskId select id; if (row.Count() > 0) { return -1; } } // Create a new mapping base.New(); CurrentRow = new tasks_call(); CurrentRow.task_id = TaskId; CurrentRow.call_id = CallId; try { CurrentConnection.tasks_calls.InsertOnSubmit(CurrentRow); CurrentConnection.SubmitChanges(); } catch (Exception) { return -1; } return Save(); }