(function () { 'use strict'; var serviceId = 'rolesService'; angular.module('roles').factory(serviceId, ['user', 'rolesDataContext', rolesService]); function rolesService(user, rolesDataContext) { var service = { createRoleAllocation: createRoleAllocation, removeRoleAllocation: removeRoleAllocation, setMyRoles: setMyRoles, getMyRoles: getMyRoles, setActiveRole: setActiveRole, getActiveRole: getActiveRole, }; return service; // The user's actual active role. var activeRole; // The collection of the user's avaialbe roles. var myRoles; function createRoleAllocation(orgId, roleName) { return user.getProfile().then(function (data) { return rolesDataContext.createRoleAllocation({ roleName: roleName, userId: data.id, organisationId: orgId, appCode: 'MS' }).then(function (alData) { console.log(alData); }); }); } function removeRoleAllocation() { } // Active role is used to hold the user's current active role. function setActiveRole(role) { activeRole = role; } function getActiveRole() { return activeRole; } // My roles is the array of the current user's available roles. function setMyRoles(roles) { myRoles = roles; } function getMyRoles() { return myRoles; } } })();