/// <summary> /// Saves the new team entity and adds the owner to the team. Optionally will /// add the owner's manager to the team is the add owner's manager checkbox is checked. /// </summary> /// <param name="form"></param> /// <param name="args"></param> public static void SaveButton_OnClickStep(IInsertTeam form, EventArgs args) { IWebDialogService dialogService = form.Services.Get <IWebDialogService>(); // create the new team IOwner ownerTeam = EntityFactory.Create <IOwner>(); ownerTeam.OwnerDescription = form.OwnerDescription.Text; ownerTeam.Type = OwnerType.Team; if (!ownerTeam.IsValidName(form.OwnerDescription.Text)) { string msg = form.GetResource("InvalidNameMessage").ToString(); if (dialogService != null && !string.IsNullOrEmpty(msg)) { dialogService.ShowMessage(msg, form.GetResource("InvalidNameMessageTitle").ToString()); } return; } if (ownerTeam.OwnerNameExists(form.OwnerDescription.Text)) { string msg = form.GetResource("DuplicateOwnerMessage").ToString(); if (dialogService != null && !string.IsNullOrEmpty(msg)) { dialogService.ShowMessage(msg, form.GetResource("DuplicateOwnerTitle").ToString()); } return; } ownerTeam.Save(); // set a default profile IOwnerSecurityProfile securityProfile = EntityFactory.GetById <IOwnerSecurityProfile>("PROF00000001"); if (form.securityProfileLookup.LookupResultValue != null) { securityProfile = form.securityProfileLookup.LookupResultValue as IOwnerSecurityProfile; } // get a team object. This is a view of the owner object ITeam team = EntityFactory.GetById <ITeam>(ownerTeam.Id); // add an ownerJoin record for the new team. Both the parent and the // child ids will point to the team team.AddMemberWithSecurityProfile(ownerTeam, securityProfile); // get the selected owner of the team. This will be a user IUser teamOwnerUser = form.DefaultOwner.LookupResultValue as IUser; if (teamOwnerUser != null) { // add the team owner as a member of the team IOwnerSecurityProfile ownerSecurityProfile = EntityFactory.GetById <IOwnerSecurityProfile>("PROF00000003"); team.AddMemberWithSecurityProfile(teamOwnerUser.DefaultOwner, ownerSecurityProfile); } MySlx.MainView.Show <ITeam>(ownerTeam.Id.ToString()); }
public static void SaveButton_OnClickStep(IInsertDepartment form, EventArgs args) { IWebDialogService dialogService = form.Services.Get <IWebDialogService>(); IOwner owner = EntityFactory.Create <IOwner>(); owner.OwnerDescription = form.OwnerDescription.Text; owner.Type = OwnerType.Department; if (!owner.IsValidName(form.OwnerDescription.Text)) { string msg = form.GetResource("InvalidNameMessage").ToString(); if (dialogService != null && !string.IsNullOrEmpty(msg)) { dialogService.ShowMessage(msg, form.GetResource("InvalidNameMessageTitle").ToString()); } return; } if (owner.OwnerNameExists(form.OwnerDescription.Text)) { string msg = form.GetResource("DuplicateOwnerMessage").ToString(); if (dialogService != null && !string.IsNullOrEmpty(msg)) { dialogService.ShowMessage(msg, form.GetResource("DuplicateOwnerTitle").ToString()); } return; } owner.Save(); IOwnerSecurityProfile securityProfile = EntityFactory.GetById <IOwnerSecurityProfile>("PROF00000001"); if (form.securityProfileLookup.LookupResultValue != null) { securityProfile = form.securityProfileLookup.LookupResultValue as IOwnerSecurityProfile; } // get a department object. This is a view of the owner object IDepartment department = EntityFactory.GetById <IDepartment>(owner.Id); // add an ownerJoin record for the new team. Both the parent and the // child ids will point to the team department.AddMemberWithSecurityProfile(owner, securityProfile); HttpContext.Current.Response.Redirect(string.Format("~/Department.aspx?entityId={0}", owner.Id.ToString()), false); }
/// <summary> /// Performs the password validation rules. If validation fails an exception is raised from the /// ValidateUserPassword method. If validation succeeds, but the password was changed /// to an empty string that result is returned, which will be displayed to the UI. /// </summary> /// <param name="form">The change password form.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> public static void btnSave_OnClick(IUserChangePassword form, EventArgs args) { string newPassword = form.txtNewPassword.Text; if (newPassword == form.txtConfirmPassword.Text) { IUser user = (IUser)form.CurrentEntity; if (user.ValidateUserPassword(newPassword)) { IWebDialogService dialogService = form.Services.Get <IWebDialogService>(); user.SavePassword(newPassword); var slxUserService = (ISlxUserService)ApplicationContext.Current.Services.Get <IUserService>(true); var currentUser = slxUserService.GetUser(); if (user.UserName == currentUser.UserName) { var data = (SLXDataService)ApplicationContext.Current.Services.Get <IDataService>(true); var auth = (SLXWebAuthenticationProvider)data.AuthenticationProvider; auth.AuthenticateWithContext(currentUser.UserName, newPassword); } form.lblInvalidPassword.Text = newPassword.Length == 0 ? form.GetResource("PasswordBlank").ToString() : String.Empty; dialogService.ShowMessage(form.GetResource(newPassword.Length == 0 ? "PasswordBlank" : "PasswordChanged").ToString()); dialogService.CloseEventHappened(form, null); IPanelRefreshService refresher = form.Services.Get <IPanelRefreshService>(); if (refresher != null) { refresher.RefreshAll(); } } } else { throw new ValidationException(form.GetResource("Error_PasswordsDontMatch").ToString()); } }