/// <summary> /// Create a New User Account in the System. /// Users are Automatically Provisioned with Default Queues. /// </summary> public User CreateUserAccount(Guid id, Agency.Agency homeAgency, string username, string password) { // Make sure the username is Unique. CheckUsername(username); var newUser = UserFactory.CreateUser(this, id, homeAgency, username, password); IdentitiesCollection.Add(newUser); return(newUser); }
/// <summary> /// Grant a Resource License to the Agency for a Module Type. /// </summary> /// <param name="agency"></param> /// <param name="moduleType"></param> /// <returns></returns> public ResourceLicense LicenseModule(Agency.Agency agency, ModuleType moduleType) { var resource = Resources.SingleOrDefault(x => x.ModuleType == moduleType); if (resource == null) { throw new Exception("The requested module is not available in this system."); } return(agency.GrantLicense(new ResourceLicense(agency, resource))); }
/// <summary> /// Create a New User Identity in the System. /// </summary> public User CreateUser(Agency.Agency homeAgency, string username, string password) { if (UsernameIsTaken(username)) { throw new Exception("Username is already in use."); } var newUser = new User(this, homeAgency, username, password); IdentitiesCollection.Add(newUser); return(newUser); }
/// <summary> /// Create a New Agency /// </summary> /// <param name="agencyName">Name of the Agency</param> /// <param name="agencyOri">Ori assigned to the Agency</param> public Agency.Agency CreateAgency(string agencyName, string agencyOri) { if (Agencies.Any(x => x.Jurisdiction.Ori == agencyOri)) { throw new Exception("ORI is already in use."); } // Create the new Agency var agency = new Agency.Agency(new Jurisdiction(agencyOri, agencyOri), agencyName); AgencyCollection.Add(agency); return(agency); }
public Agency.Agency CreateAgency(Guid id, string agencyName, string agencyOri) { if (Agencies.Any(x => x.Jurisdiction.Ori == agencyOri)) { throw new Exception("Cannot create a new Agency with an existing ORI."); } var agency = new Agency.Agency(new Jurisdiction(agencyOri, agencyOri), agencyName); // TODO: Default Roles and Permissions and Resources AgencyCollection.Add(agency); return(agency); }
/// <summary> /// Set the Primary Agency for this User. /// </summary> public void SetPrimaryAgency(Agency.Agency agency) { if (agency == null) { throw new Exception("User's Must belong to an Agency."); } // The User can only be associated to an Officer in their Primary Agency. if (AgencyOfficer != null && AgencyOfficer.AgencyId != agency.Id) { AgencyOfficer = null; AgencyOfficerId = Guid.Empty; } PrimaryAgency = agency; PrimaryAgencyId = agency.Id; }
/// <summary> /// Create a new User in the system. /// </summary> /// <param name="rmsSystem">The RMSSystem instance.</param> /// <param name="id">Explicit Id for the new user. If empty the system will generate one.</param> /// <param name="homeAgency">Home Agency for the new User.</param> /// <param name="username">Username for the new User.</param> /// <param name="password">Password for the new User.</param> /// <returns></returns> public static User CreateUser(RMSSystem.RMSSystem rmsSystem, Guid id, Agency.Agency homeAgency, string username, string password) { // Create a New User var newUser = new User(id, rmsSystem, homeAgency, username); // Set the User's Password newUser.ChangePassword(password); // Provision Default Queues newUser.AddQueue(new Queue(QueueType.Incident)); newUser.AddQueue(new Queue(QueueType.InProgress)); newUser.AddQueue(new Queue(QueueType.Case)); newUser.AddQueue(new Queue(QueueType.Approval)); // Make the User Active newUser.MakeActive(); return(newUser); }
internal User(Guid id, RMSSystem.RMSSystem rmsSystem, Agency.Agency primaryAgency, string username) : base(id, rmsSystem, username, IdentityType.User) { SetPrimaryAgency(primaryAgency); Unlock(); }
/// <summary> /// Create a New User Account in the System. /// </summary> public User CreateUserAccount(Agency.Agency homeAgency, string username, string password) { return(CreateUserAccount(Guid.Empty, homeAgency, username, password)); }