/// <summary> /// To the model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> internal static ModelSystemUser ToModel(this EntitySystemUser entity) { var model = new ModelSystemUser(); model.Id = entity.Id; model.Username = entity.Username; model.FirstName = entity.FirstName; model.LastName = entity.LastName; model.Password = entity.Password; model.EmailAddress = entity.EmailAddress; model.PhoneNumber = entity.PhoneNumber; model.MobileNumber = entity.MobileNumber; model.StreetId = entity.StreetId; model.House = entity.House; model.Street = entity.Street; model.Suburb = entity.Suburb; model.Town = entity.Town; model.Province = entity.Province; model.Country = entity.Country; return(model); }
/// <summary> /// Gets the system user. /// </summary> /// <returns></returns> public async Task <ModelSystemUser> GetSystemUser() { using (var db = new MancobaLocalDataApi(_connectionFactory, _platformCapabilities)) { if (_systemUser == null) { var response = await db.GetAnySystemUser(); _systemUser = response.ToModel(); } return(_systemUser); } }
/// <summary> /// Logins the specified email address. /// </summary> /// <param name="emailAddress">The email address.</param> /// <param name="password">The password.</param> /// <returns></returns> public async Task <ModelSystemUser> Login(string emailAddress, string password) { TestData.ConnectionFactory = _connectionFactory; TestData.PlatformCapabilities = _platformCapabilities; using (var db = new MancobaLocalDataApi(_connectionFactory, _platformCapabilities)) { var response = await db.Login(emailAddress, password); if (response == null) { response = await TestData.GetSystemUser(emailAddress, password); } return(_systemUser = response.ToModel()); } }
/// <summary> /// Run asynchroniously to not stop XrmToolBox. /// </summary> private void OnIndexChanged(CheckedListBox listBox) { // Prevent from further clicking this.SetAllEnable(false); // Uncheck everything listBox.ClearAllSelections(); // Set as checked only checked item listBox.SetItemCheckState(listBox.SelectedIndex, CheckState.Checked); // Checked User var userIndex = listBox.SelectedIndex; // Checked Model connected with User CurrentSelectedUser = this.Users.ElementAt(userIndex); // Calculate permissions for selected User CalculatePermissions(); // After everything enable - enable Roles for future plans this.SetAllEnable(true); }
/// <summary> /// To the entity. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> internal static EntitySystemUser ToEntity(this ModelSystemUser model) { var entity = new EntitySystemUser(); entity.Id = model.Id; entity.Username = model.Username; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Password = model.Password; entity.EmailAddress = model.EmailAddress; entity.PhoneNumber = model.PhoneNumber; entity.MobileNumber = model.MobileNumber; entity.StreetId = model.StreetId; entity.House = model.House; entity.Street = model.Street; entity.Suburb = model.Suburb; entity.Town = model.Town; entity.Province = model.Province; entity.Country = model.Country; return(entity); }
/// <summary> /// Initialises this instance. /// </summary> private void Initialise() { _systemUser = null; _isAuthenticated = false; _authenticatedMessage = null; }
/// <summary> /// Returns actual Fetch XML <see cref="string"/> for <see cref="FetchQueries.GetRolesForUser"/>. /// </summary> public static string GetRolesForUser(ModelSystemUser user) { return(GetRolesForUser(user.SystemUserId)); }
/// <summary> /// Saves the system user. /// </summary> /// <param name="user">The user.</param> /// <returns></returns> public async Task <bool> SaveSystemUser(ModelSystemUser user) { return(await Task.Run(() => true)); }