partial void DeleteRoleHierarchy(RoleHierarchy instance);
 partial void UpdateRoleHierarchy(RoleHierarchy instance);
 partial void InsertRoleHierarchy(RoleHierarchy instance);
		private void detach_RoleHierarchy1(RoleHierarchy entity)
		{
			this.SendPropertyChanging();
			entity.Role1 = null;
		}
		private void attach_RoleHierarchy(RoleHierarchy entity)
		{
			this.SendPropertyChanging();
			entity.Role = this;
		}
Exemple #6
0
        public static Program.ExitCode AddRH(Role senior, Role junior, rbacLINQ2SQLDataContext db)
        {
            // Check if roles exist
            var roleS = from r in db.Role
                        where r.Name == senior.Name && r.Policy_Id == senior.Policy_Id
                        select r;
            var roleJ = from r in db.Role
                        where r.Name == junior.Name && r.Policy_Id == junior.Policy_Id
                        select r;
            if (roleS.Count() == 1 && roleJ.Count() == 1)
            {
                RoleHierarchy rh = new RoleHierarchy()
                {
                    SeniorRole_Id = roleS.First().Id,
                    JuniorRole_Id = roleJ.First().Id,
                };

                // Check if RH exists:
                var query = from t in db.RoleHierarchy
                            where  t.SeniorRole_Id == rh.SeniorRole_Id
                                && t.JuniorRole_Id == rh.JuniorRole_Id
                            select t;
                if (query.Count() == 1)
                {
                    return Program.ExitCode.ElementExists;
                }
                try
                {
                    db.RoleHierarchy.InsertOnSubmit(rh);
                    db.SubmitChanges();
                    return Program.ExitCode.Success;
                }
                catch
                {
                    return Program.ExitCode.Error;
                }
            }
            else
            {
                return Program.ExitCode.ElementDoesNotExists;
            }
        }