Пример #1
0
 partial void DeleteRoleHierarchy(RoleHierarchy instance);
Пример #2
0
 partial void UpdateRoleHierarchy(RoleHierarchy instance);
Пример #3
0
 partial void InsertRoleHierarchy(RoleHierarchy instance);
Пример #4
0
		private void detach_RoleHierarchy1(RoleHierarchy entity)
		{
			this.SendPropertyChanging();
			entity.Role1 = null;
		}
Пример #5
0
		private void attach_RoleHierarchy(RoleHierarchy entity)
		{
			this.SendPropertyChanging();
			entity.Role = this;
		}
Пример #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;
            }
        }