partial void DeleteDynamicSOD(DynamicSOD instance);
partial void UpdateDynamicSOD(DynamicSOD instance);
partial void InsertDynamicSOD(DynamicSOD instance);
private void detach_DynamicSOD1(DynamicSOD entity) { this.SendPropertyChanging(); entity.Role1 = null; }
private void attach_DynamicSOD1(DynamicSOD entity) { this.SendPropertyChanging(); entity.Role1 = this; }
public static Program.ExitCode AddDynamicSOD(Role r1, Role r2, rbacLINQ2SQLDataContext db) { // Check if roles exist var role1 = from r in db.Role where r.Name == r1.Name && r.Policy_Id == r1.Policy_Id select r; var role2 = from r in db.Role where r.Name == r2.Name && r.Policy_Id == r2.Policy_Id select r; if (role1.Count() == 1 || role2.Count() == 1) { DynamicSOD dsod1 = new DynamicSOD() { Role_Id = role1.First().Id, ExclusiveRole_Id = role2.First().Id, }; DynamicSOD dsod2 = new DynamicSOD() { Role_Id = role2.First().Id, ExclusiveRole_Id = role1.First().Id, }; // Check if DSOD exists: var query1 = from t in db.DynamicSOD where t.Role_Id == dsod1.Role_Id && t.ExclusiveRole_Id == dsod1.ExclusiveRole_Id select t; var query2 = from t in db.DynamicSOD where t.Role_Id == dsod2.Role_Id && t.ExclusiveRole_Id == dsod2.ExclusiveRole_Id select t; if (query1.Count() == 1 && query2.Count() == 1) { return Program.ExitCode.ElementExists; } try { if (query1.Count() != 1) db.DynamicSOD.InsertOnSubmit(dsod1); if (query2.Count() != 1) db.DynamicSOD.InsertOnSubmit(dsod2); db.SubmitChanges(); return Program.ExitCode.Success; } catch { return Program.ExitCode.Error; } } else { return Program.ExitCode.ElementDoesNotExists; } }