public async Task <IActionResult> CreateOrganizationUser(OrganizationUser organizationUser) { await _context.OrganizationUser.AddAsync(organizationUser); await _context.SaveChangesAsync(); return(Ok(organizationUser)); }
public void UserOrg_userAdd(int org_Id, int user_Id) { OrganizationUser gg = new OrganizationUser(); gg.Organizations = _orgRep.Find(org_Id); gg.Users = _userRep.Find(user_Id); _OrgUserRep.Add(gg); }
public async Task InviteUser_NoEmails_Throws(Organization organization, OrganizationUser invitor, OrganizationUserInvite invite, SutProvider <OrganizationService> sutProvider) { invite.Emails = null; sutProvider.GetDependency <IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization); await Assert.ThrowsAsync <NotFoundException>( () => sutProvider.Sut.InviteUserAsync(organization.Id, invitor.UserId, null, invite)); }
private void SetUserAttributes(int accountId) { OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, accountId); ES.Services.Organizations.SetUserGeneralSettings(PanelRequest.ItemID, accountId, txtDisplayName.Text, null, false, user.Disabled, user.Locked, txtFirstName.Text, txtInitials.Text, txtLastName.Text, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, user.ExternalEmail, txtSubscriberNumber.Text, 0, false, false); }
public int SetUserPassword(int itemId, int accountId, string password) { // load account OrganizationUser user = OrganizationController.GetAccount(itemId, accountId); int res = OrganizationController.SetUserPassword(itemId, accountId, password); return(res); }
private async Task SendInviteAsync(OrganizationUser orgUser) { var org = await _organizationRepository.GetByIdAsync(orgUser.OrganizationId); var nowMillis = CoreHelpers.ToEpocMilliseconds(DateTime.UtcNow); var token = _dataProtector.Protect( $"OrganizationUserInvite {orgUser.Id} {orgUser.Email} {nowMillis}"); await _mailService.SendOrganizationInviteEmailAsync(org.Name, orgUser, token); }
public async Task SaveUser_NoUserId_Throws(OrganizationUser user, Guid?savingUserId, IEnumerable <SelectionReadOnly> collections, SutProvider <OrganizationService> sutProvider) { user.Id = default(Guid); var exception = await Assert.ThrowsAsync <BadRequestException>( () => sutProvider.Sut.SaveUserAsync(user, savingUserId, collections)); Assert.Contains("invite the user first", exception.Message.ToLowerInvariant()); }
public int DeleteUser(int itemId, int accountId) { // load account OrganizationUser user = OrganizationController.GetAccount(itemId, accountId); int res = OrganizationController.DeleteUser(itemId, accountId); return(res); }
public async Task <OrganizationUser> InviteUserAsync(Guid organizationId, Guid invitingUserId, string email, OrganizationUserType type, bool accessAll, string externalId, IEnumerable <SelectionReadOnly> collections) { var organization = await _organizationRepository.GetByIdAsync(organizationId); if (organization == null) { throw new NotFoundException(); } if (organization.Seats.HasValue) { var userCount = await _organizationUserRepository.GetCountByOrganizationIdAsync(organizationId); if (userCount >= organization.Seats.Value) { throw new BadRequestException("You have reached the maximum number of users " + $"({organization.Seats.Value}) for this organization."); } } // Make sure user is not already invited var existingOrgUser = await _organizationUserRepository.GetByOrganizationAsync(organizationId, email); if (existingOrgUser != null) { throw new BadRequestException("User already invited."); } var orgUser = new OrganizationUser { OrganizationId = organizationId, UserId = null, Email = email.ToLowerInvariant(), Key = null, Type = type, Status = OrganizationUserStatusType.Invited, AccessAll = accessAll, ExternalId = externalId, CreationDate = DateTime.UtcNow, RevisionDate = DateTime.UtcNow }; if (!orgUser.AccessAll && collections.Any()) { await _organizationUserRepository.CreateAsync(orgUser, collections); } else { await _organizationUserRepository.CreateAsync(orgUser); } await SendInviteAsync(orgUser); return(orgUser); }
private bool CreateUser(int index, int orgId, string displayName, string emailAddress, string password, string firstName, string middleName, string lastName, string address, string city, string state, string zip, string country, string jobTitle, string company, string department, string office, string businessPhone, string fax, string homePhone, string mobilePhone, string pager, string webPage, string notes) { bool ret = false; try { string name = emailAddress.Substring(0, emailAddress.IndexOf("@")); string domain = emailAddress.Substring(emailAddress.IndexOf("@") + 1); string accountName = string.Empty; int accountId = ES.Services.Organizations.CreateUser(orgId, displayName, name, domain, password, false, string.Empty); if (accountId < 0) { string errorMessage = GetErrorMessage(accountId); Log.WriteError(string.Format("Error at line {0}: {1}", index + 1, errorMessage)); return(false); } OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(orgId, accountId); user.FirstName = firstName; user.Initials = middleName; user.LastName = lastName; user.Address = address; user.City = city; user.State = state; user.Zip = zip; user.Country = country; user.JobTitle = jobTitle; user.Company = company; user.Department = department; user.Office = office; user.BusinessPhone = businessPhone; user.Fax = fax; user.HomePhone = homePhone; user.MobilePhone = mobilePhone; user.Pager = pager; user.WebPage = webPage; user.Notes = notes; //update ES.Services.Organizations.SetUserGeneralSettings(orgId, accountId, user.DisplayName, null, false, user.Disabled, user.Locked, user.FirstName, user.Initials, user.LastName, user.Address, user.City, user.State, user.Zip, user.Country, user.JobTitle, user.Company, user.Department, user.Office, null, user.BusinessPhone, user.Fax, user.HomePhone, user.MobilePhone, user.Pager, user.WebPage, user.Notes, user.ExternalEmail); ret = true; } catch (Exception ex) { Log.WriteError(string.Format("Error at line {0}: Unable to create user", index + 1), ex); } return(ret); }
public OrganizationUser ToOrganizationUser(OrganizationUser existingUser) { existingUser.Type = Type.Value; existingUser.Permissions = JsonSerializer.Serialize(Permissions, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }); existingUser.AccessAll = AccessAll; return(existingUser); }
public IOrganizationUser UpdateUser(int organizationId, int userId, EmployeeRole role, bool isApproved) { OrganizationUser organizationUser = _GetOrganizationUser(_Context, organizationId, userId); organizationUser.IsApproved = isApproved; organizationUser.UserRole = (int)role; _Context.SubmitChanges(); return(organizationUser); }
public OrganizationExtendedResponseModel(Organization organization, OrganizationUser organizationUser) : base(organization, "organizationExtended") { if (organizationUser == null) { throw new ArgumentNullException(nameof(organizationUser)); } Key = organizationUser.Key; }
private void RegisterButton_Clicked(object sender, RoutedEventArgs e) { try { if (VerificateFields()) { OrganizationUserApi organizationtUserApi = new OrganizationUserApi(); OrganizationUser organizationUser = new OrganizationUser(name: NameTextBox.Text, contactEmail: AgentEmailTextBox.Text); User generalUser = new User(email: EmailTextBox.Text); Media perfilImage = new Media(); generalUser.City = CityTextBox.Text; generalUser.Country = CountryTextBox.Text; generalUser.Password = Encrypt.GetSHA256(PasswordTextBox.Password); if (myStream != null) { using (MemoryStream ms = new MemoryStream()) { myStream.CopyTo(ms); byte[] imageFile = ms.ToArray(); perfilImage.File = imageFile; generalUser.ProfilePhoto = perfilImage; } } organizationUser.About = DescripctionTextBox.Text; organizationUser.ContactPhone = PhoneTextBox.Text; organizationUser.ContactName = AgentTextBox.Text; organizationUser.ZipCode = Convert.ToInt32(PostalCodeTextBox.Text); organizationUser.WebSite = WebSiteTextBox.Text; organizationUser.WorkSector = (Sector)SectorComboBox.SelectedItem; organizationUser.User = generalUser; var response = organizationtUserApi.RegisterOrganizationUserWithHttpInfo(organizationUser); CustomMessageBox.ShowOK("El usuario ha sido registrado con éxito.", "Registro exitoso", "Aceptar"); var mainWindow = (MainWindow)Application.Current.MainWindow; mainWindow?.ChangeView(new ValidateUser(organizationUser.User.Email, organizationUser.Name)); return; } } catch (ApiException ex) { if (ex.ErrorCode == 401) { CustomMessageBox.ShowOK("Ya existe un usuario con el correo " + EmailTextBox.Text, "Usuario existente", "Aceptar"); } if (ex.ErrorCode == 500) { CustomMessageBox.ShowOK("Ocurrió un error en la conexión con la base de datos. Por favor intentelo más tarde", "Error de conexión", "Aceptar"); Restarter.RestarEmployex(); } } }
public MemberBaseModel(OrganizationUser user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } Type = user.Type; AccessAll = user.AccessAll; ExternalId = user.ExternalId; }
private Task HandleSuccess(string username, OrganizationUser orgUser, IMessageHandlerContext context) { var data = orgUser.SerializeMessage(); return(context.Publish <IOrganizationUserCreated>(e => { e.Username = username; e.OrganizationUser = new EntityReference(orgUser.Id, orgUser.Username); e.SerializedData = data; })); }
public async Task ResendSponsorshipOffer_SponsoringOrgNotFound_ThrowsBadRequest( OrganizationUser orgUser, OrganizationSponsorship sponsorship, SutProvider <SendSponsorshipOfferCommand> sutProvider) { var exception = await Assert.ThrowsAsync <BadRequestException>(() => sutProvider.Sut.SendSponsorshipOfferAsync(null, orgUser, sponsorship)); Assert.Contains("Cannot find the requested sponsoring organization.", exception.Message); await sutProvider.GetDependency <IMailService>() .DidNotReceiveWithAnyArgs() .SendFamiliesForEnterpriseOfferEmailAsync(default, default, default, default);
protected override void Seed(NotesContext context) { User system = new User { Name = NotesContext.ContextUserName, PasswordHash = NotesContext.ContextPasswordHash, PasswordSalt = NotesContext.ContextPasswordSalt, IsSystemOnly = true }; context.Users.Add(system); Role role = new Role { Name = NotesContext.ContextRoleName, IsSystemOnly = true }; context.Roles.Add(role); Organization org = new Organization { Name = NotesContext.ContextOrganizationName, IsSystemOnly = true }; context.Organizations.Add(org); OrganizationRole orgRole = new OrganizationRole { Organization = org, Role = role }; context.OrganizationRoles.Add(orgRole); OrganizationRoleUser systemOrgRole = new OrganizationRoleUser { User = system, OrganizationRole = orgRole }; context.OrganizationRoleUsers.Add(systemOrgRole); OrganizationUser systemOrg = new OrganizationUser { User = system, Organization = org }; context.OrganizationUsers.Add(systemOrg); base.Seed(context); }
public async Task SaveUser_NoChangeToData_Throws(OrganizationUser user, Guid?savingUserId, IEnumerable <SelectionReadOnly> collections, SutProvider <OrganizationService> sutProvider) { var organizationUserRepository = sutProvider.GetDependency <IOrganizationUserRepository>(); organizationUserRepository.GetByIdAsync(user.Id).Returns(user); var exception = await Assert.ThrowsAsync <BadRequestException>( () => sutProvider.Sut.SaveUserAsync(user, savingUserId, collections)); Assert.Contains("make changes before saving", exception.Message.ToLowerInvariant()); }
public async Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, string token) { try { await _primaryMailService.SendOrganizationInviteEmailAsync(organizationName, orgUser, token); } catch (Exception e) { LogError(e); await _backupMailService.SendOrganizationInviteEmailAsync(organizationName, orgUser, token); } }
protected void btnupdatedown_Click(object sender, EventArgs e) { string strfolderpath = "/Images/TestUpload/"; // Loop through each Image control var currentSession = IoC.Resolve <ISessionContext>().UserSession; EFranchiseeUser franchiseeuser = OrganizationUser.GetFranchiseeUser(currentSession); string strtemp = string.Empty; strtemp = ucmyphoto.SaveImage(strfolderpath + "MyPic" + DateTime.Now.ToString("yyyyMMddhhmmss")); if (strtemp != string.Empty) { franchiseeuser.MyPicture = "~" + strtemp; } strtemp = ucteamphoto.SaveImage(strfolderpath + "TeamPic" + DateTime.Now.ToString("yyyyMMddhhmmss")); if (strtemp != string.Empty) { franchiseeuser.TeamPicture = "~" + strtemp; } for (Int16 icount = 0; icount < 12; icount++) { UCCommon_ucphotopanel Ucphotopanel1 = (UCCommon_ucphotopanel)grdphotoother.Rows[icount].FindControl("Ucphotopanel1"); strtemp = Ucphotopanel1.SaveImage(strfolderpath + icount + DateTime.Now.ToString("yyyyMMddhhmmss")); if (strtemp != string.Empty) { franchiseeuser.OtherPictures[icount] = "~" + strtemp; } } var usershellmodulerole1 = new Falcon.Entity.User.EUserShellModuleRole(); usershellmodulerole1.RoleID = currentSession.CurrentOrganizationRole.RoleId.ToString(); usershellmodulerole1.ShellID = currentSession.CurrentOrganizationRole.OrganizationId.ToString(); usershellmodulerole1.UserID = currentSession.UserId.ToString(); var franchiseeDal = new FranchiseeDAL(); long returnresult = franchiseeDal.SaveFranchiseeUserImages(franchiseeuser, Convert.ToInt32(EOperationMode.Update), usershellmodulerole1.UserID, usershellmodulerole1.ShellID, usershellmodulerole1.RoleID); if (returnresult == 0) { returnresult = 9999991; } System.Text.StringBuilder strJSCloseWindow = new System.Text.StringBuilder(); strJSCloseWindow.Append(" <script language = 'Javascript'>window.close(); </script>"); ClientScript.RegisterStartupScript(typeof(string), "JSCode", strJSCloseWindow.ToString()); }
protected int ChangeUsersSettings(List <int> userIds, bool?disable, int?serviceLevelId, bool?isVIP) { foreach (var userId in userIds) { OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, userId); int result = ES.Services.Organizations.SetUserGeneralSettings( PanelRequest.ItemID, userId, user.DisplayName, string.Empty, false, disable ?? user.Disabled, user.Locked, user.FirstName, user.Initials, user.LastName, user.Address, user.City, user.State, user.Zip, user.Country, user.JobTitle, user.Company, user.Department, user.Office, user.Manager != null ? user.Manager.AccountName : String.Empty, user.BusinessPhone, user.Fax, user.HomePhone, user.MobilePhone, user.Pager, user.WebPage, user.Notes, user.ExternalEmail, user.SubscriberNumber, serviceLevelId ?? user.LevelId, isVIP ?? user.IsVIP, user.UserMustChangePassword); if (result < 0) { return(result); } } return(0); }
private async Task <Tuple <Organization, OrganizationUser> > SignUpAsync(Organization organization, Guid ownerId, string ownerKey, string collectionName, bool withPayment) { try { await _organizationRepository.CreateAsync(organization); var orgUser = new OrganizationUser { OrganizationId = organization.Id, UserId = ownerId, Key = ownerKey, Type = OrganizationUserType.Owner, Status = OrganizationUserStatusType.Confirmed, AccessAll = true, CreationDate = organization.CreationDate, RevisionDate = organization.CreationDate }; await _organizationUserRepository.CreateAsync(orgUser); if (!string.IsNullOrWhiteSpace(collectionName)) { var defaultCollection = new Collection { Name = collectionName, OrganizationId = organization.Id, CreationDate = organization.CreationDate, RevisionDate = organization.CreationDate }; await _collectionRepository.CreateAsync(defaultCollection); } // push var deviceIds = await GetUserDeviceIdsAsync(orgUser.UserId.Value); await _pushRegistrationService.AddUserRegistrationOrganizationAsync(deviceIds, organization.Id.ToString()); await _pushNotificationService.PushSyncOrgKeysAsync(ownerId); return(new Tuple <Organization, OrganizationUser>(organization, orgUser)); } catch { if (organization.Id != default(Guid)) { await _organizationRepository.DeleteAsync(organization); } throw; } }
private void BindAddresses() { OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID); if (user == null) { return; } if (user.AccountType == ExchangeAccountType.Mailbox) { email.Visible = false; ddlSipAddresses.Visible = true; SolidCP.EnterpriseServer.ExchangeEmailAddress[] emails = ES.Services.ExchangeServer.GetMailboxEmailAddresses(PanelRequest.ItemID, PanelRequest.AccountID); foreach (SolidCP.EnterpriseServer.ExchangeEmailAddress mail in emails) { ListItem li = new ListItem(); li.Text = mail.EmailAddress; li.Value = mail.EmailAddress; li.Selected = mail.IsPrimary; ddlSipAddresses.Items.Add(li); } foreach (ListItem li in ddlSipAddresses.Items) { if (li.Value == sipAddressToSelect) { ddlSipAddresses.ClearSelection(); li.Selected = true; break; } } } else { email.Visible = true; ddlSipAddresses.Visible = false; if (!string.IsNullOrEmpty(sipAddressToSelect)) { string[] Tmp = sipAddressToSelect.Split('@'); email.AccountName = Tmp[0]; if (Tmp.Length > 1) { email.DomainName = Tmp[1]; } } } }
public MemberResponseModel(OrganizationUser user, IEnumerable <SelectionReadOnly> collections) : base(user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } Id = user.Id; Email = user.Email; Status = user.Status; Collections = collections?.Select(c => new AssociationWithPermissionsResponseModel(c)); }
private async Task CreateOrganizationUser(Organization organization, CancellationToken cancellationToken) { var organizationUser = new OrganizationUser { OrganizationId = organization.Id, UserId = _currentUser.UserId, Type = Domain.Enums.UserType.Admin }; await _context.OrganizationUsers.AddAsync(organizationUser); await _context.SaveChangesAsync(cancellationToken); }
public OrganizationUserEvent(OrganizationUser organizationUser, Guid actingUserId, EventType type) { OrganizationId = organizationUser.OrganizationId; UserId = organizationUser.UserId; OrganizationUserId = organizationUser.Id; Type = (int)type; ActingUserId = actingUserId; Timestamp = DateTime.UtcNow; PartitionKey = $"OrganizationId={OrganizationId}"; RowKey = string.Format("Date={0}__ActingUserId={1}__Type={2}", CoreHelpers.DateTimeToTableStorageKey(Timestamp.DateTime), ActingUserId, Type); }
public ScimUser(OrganizationUser orgUser) { Id = orgUser.Id.ToString(); ExternalId = orgUser.ExternalId; UserName = orgUser.Email; Active = true; Emails = new List <ScimMultiValuedAttribute> { new ScimMultiValuedAttribute { Type = "work", Value = orgUser.Email } }; Meta = new ScimResourceMetadata("User"); }
public async Task <Organization> AddUser(string organizationId, string userId, string role) { OrganizationUser ou = new OrganizationUser(); ou.Role = role; ou.OrganizationId = organizationId; ou.UserId = userId; await _context.OrganizationUsers.AddAsync(ou); await _context.SaveChangesAsync(); return(await GetOrganization(organizationId)); }
public OrganizationUserResponseModel(OrganizationUser organizationUser, string obj = "organizationUser") : base(obj) { if (organizationUser == null) { throw new ArgumentNullException(nameof(organizationUser)); } Id = organizationUser.Id.ToString(); UserId = organizationUser.UserId?.ToString(); Type = organizationUser.Type; Status = organizationUser.Status; AccessAll = organizationUser.AccessAll; }