/// <summary>
 /// Initializes a new instance of the RoleSvc class by creating a object of RoleDao class.
 /// </summary>
 public UserRoleAssignmentSvc()
 {
     this.userRoleAssignmentDao = new UserRoleAssignmentDao();
     this.userSvc = GatekeeperFactory.UserSvc;
     this.roleSvc = GatekeeperFactory.RoleSvc;
     this.appSvc = GatekeeperFactory.ApplicationSvc;
 }
        public void Save(Application application, User user, Role role, SecurableObject securableObject)
        {
            UserRoleAssignmentDao uraDao = new UserRoleAssignmentDao();
            //long securableObjectId = new SecurableObjectDao().GetId(securableObject.SecurableObjectGuid);
            UserRoleAssignment ura = uraDao.Get(application, user, securableObject);

            if (ura == null)
            {
                ura = new UserRoleAssignment()
                {
                    Application = application,
                    User = user,
                    Role = role,
                    SecurableObjectId = securableObject.Id
                };

                uraDao.Add(ura);
            }
            else
            {
                ura.Role = role;
                uraDao.Update(ura);
            }
        }