예제 #1
0
 /// <summary>
 /// Bind data and config the controls (buttons view, CountryStateCityEditMode)
 /// </summary>
 public void LoadControl()
 {
     organizationComponent           = new OrganizationComponent(organizationId);
     organizationId                  = organizationComponent.Organization.OrganizationID;
     btnEditProfile.CommandArgument  = "EDIT";
     btnEditProfile2.CommandArgument = "EDIT";
     FillData();
     btnEditProfile.Visible  = EnabledButtons;
     btnEditProfile2.Visible = EnabledButtons;
     PopulateLabels();
     CountryStateCityEditMode.UpdateMap();
     CountryStateCityViewMode.UpdateMap();
 }
예제 #2
0
    /// <summary>
    /// Save and update information of the organization
    /// </summary>
    /// <returns>status of save</returns>
    public bool SaveData()
    {
        try
        {
            NexsoProDAL.MIFNEXSOEntities mifnexsoEntities = new MIFNEXSOEntities();
            mifnexsoEntities.Connection.Open();
            var trans = mifnexsoEntities.Connection.BeginTransaction();
            try
            {
                if (organizationComponent.Organization.OrganizationID == Guid.Empty)
                {
                    organizationComponent.Organization.Created = DateTime.Now;
                    organizationComponent.Organization.Updated = organizationComponent.Organization.Created.GetValueOrDefault(DateTime.Now);
                }
                else
                {
                    organizationComponent.Organization.Updated = DateTime.Now;
                }
                organizationComponent.Organization.Name        = ValidateSecurity.ValidateString(txtInstitutionName.Text, false);
                organizationComponent.Organization.Description = ValidateSecurity.ValidateString(txtDescription.Text, false);
                organizationComponent.Organization.ZipCode     = CountryStateCityEditMode.SelectedPostalCode;
                organizationComponent.Organization.Phone       = ValidateSecurity.ValidateString(txtPhone.Text, false);
                organizationComponent.Organization.Skype       = ValidateSecurity.ValidateString(txtSkype.Text, false);
                organizationComponent.Organization.Twitter     = ValidateSecurity.ValidateString(txtTwitter.Text, false);
                organizationComponent.Organization.Facebook    = ValidateSecurity.ValidateString(txtFacebook.Text, false);
                organizationComponent.Organization.GooglePlus  = ValidateSecurity.ValidateString(txtGoogle.Text, false);
                organizationComponent.Organization.LinkedIn    = ValidateSecurity.ValidateString(txtLinkedIn.Text, false);
                organizationComponent.Organization.Address     = ValidateSecurity.ValidateString(CountryStateCityEditMode.SelectedAddress, false);
                organizationComponent.Organization.Country     = CountryStateCityEditMode.SelectedCountry;
                organizationComponent.Organization.Region      = CountryStateCityEditMode.SelectedState;
                organizationComponent.Organization.City        = CountryStateCityEditMode.SelectedCity;
                organizationComponent.Organization.Latitude    = CountryStateCityEditMode.SelectedLatitude;
                organizationComponent.Organization.Longitude   = CountryStateCityEditMode.SelectedLongitude;
                CountryStateCityViewMode.SelectedAddress       = ValidateSecurity.ValidateString(CountryStateCityEditMode.SelectedAddress, false);
                CountryStateCityViewMode.SelectedCountry       = CountryStateCityEditMode.SelectedCountry;
                CountryStateCityViewMode.SelectedState         = CountryStateCityEditMode.SelectedState;
                CountryStateCityViewMode.SelectedCity          = CountryStateCityEditMode.SelectedCity;
                CountryStateCityViewMode.SelectedLatitude      = CountryStateCityEditMode.SelectedLatitude;
                CountryStateCityViewMode.SelectedLongitude     = CountryStateCityEditMode.SelectedLongitude;
                CountryStateCityViewMode.SelectedPostalCode    = CountryStateCityEditMode.SelectedPostalCode;
                CountryStateCityViewMode.UpdateMap();
                organizationComponent.Organization.Email = txtEmail.Text;
                string newImg = Path.GetFileName(imgInstitution.ImageUrl);
                if (organizationComponent.Organization.Logo != newImg && newImg.ToUpper() != "NOIMAGE.PNG")
                {
                    File.Move(Server.MapPath(PortalSettings.HomeDirectory + "ModIma/TempImages/" + newImg), Server.MapPath(PortalSettings.HomeDirectory + "ModIma/Images/" + newImg));
                    imgInstitution.ImageUrl = PortalSettings.HomeDirectory + "ModIma/Images/" + newImg;
                    organizationComponent.Organization.Logo = newImg;
                }
                if (organizationComponent.Save() > 0)
                {
                    if (organizationId == Guid.Empty)
                    {
                        UserInfo userInfo = UserController.Instance.GetCurrentUserInfo();
                        organizationId = organizationComponent.Organization.OrganizationID;

                        UserOrganizationComponent userOrganizationComponent = new UserOrganizationComponent(
                            userInfo.UserID, organizationId, 1);
                        userOrganizationComponent.ChangeContext(ref mifnexsoEntities);
                        if (userOrganizationComponent.Save() < 0)
                        {
                            throw new Exception();
                        }
                    }
                }
                else
                {
                    throw new Exception();
                }
                mifnexsoEntities.AcceptAllChanges();
                trans.Commit();
                mifnexsoEntities.Dispose();
                organizationId = organizationComponent.Organization.OrganizationID;
                return(true);
            }
            catch (Exception exc)
            {
                trans.Rollback();
                mifnexsoEntities.Dispose();
                Exceptions.
                ProcessModuleLoadException(
                    this, exc);
                return(false);
            }
        }
        catch (Exception exc)
        {
            Exceptions.
            ProcessModuleLoadException(
                this, exc);
            return(false);
        }
    }
예제 #3
0
    /// <summary>
    /// Changes the view to edit mode
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnEditProfile_Click1(object sender, EventArgs e)
    {
        if (btnEditProfile.CommandArgument == "EDIT")
        {
            PopulateControls();
            setControl("EDIT");
        }
        else if (btnEditProfile.CommandArgument == "CREATE")
        {
            int userIdTmp = AddUser();

            if (userId == -1000)
            {
                userId = userIdTmp;
                SaveChkControl("Theme", chkTheme);
                Response.Redirect(NexsoHelper.GetCulturedUrlByTabName("My Nexso") + "/ui/" + userId,
                                  false);
            }
            else if (userIdTmp >= 0)
            {
                userId = userIdTmp;
                SaveChkControl("Theme", chkTheme);
                Response.Redirect(NexsoHelper.GetCulturedUrlByTabName("Discover solutions"),
                                  false);
            }
        }
        else if (btnEditProfile.CommandArgument == "EDITING")
        {
            btnEditProfile.CommandArgument = "EDIT";
            btnEditProfile.Text            = Localization.GetString("EditProfile",
                                                                    LocalResourceFile);
            UserPropertyComponent userProperty = new UserPropertyComponent(userId);
            UserInfo myDnnUser = currentUser;
            myDnnUser.Profile.InitialiseProfile(myDnnUser.PortalID);
            SaveProfile(myDnnUser);
            UserController.UpdateUser(myDnnUser.PortalID, myDnnUser);
            var sw = SaveProfile(userProperty.UserProperty);
            CountryStateCityViewMode.SelectedAddress    = CountryStateCityEditMode.SelectedAddress;
            CountryStateCityViewMode.SelectedCity       = CountryStateCityEditMode.SelectedCity;
            CountryStateCityViewMode.SelectedState      = CountryStateCityEditMode.SelectedState;
            CountryStateCityViewMode.SelectedCountry    = CountryStateCityEditMode.SelectedCountry;
            CountryStateCityViewMode.SelectedPostalCode = CountryStateCityEditMode.SelectedPostalCode;
            CountryStateCityViewMode.SelectedLongitude  = CountryStateCityEditMode.SelectedLongitude;
            CountryStateCityViewMode.SelectedLatitude   = CountryStateCityEditMode.SelectedLatitude;
            CountryStateCityViewMode.UpdateMap();
            if (sw >= 0)
            {
                userProperty.Save();
            }
            else
            {
                return;
            }
            SaveChkControl("Theme", chkTheme);
            SaveChkControl("Beneficiaries", chkBeneficiaries);
            SaveChkControl("Sector", chkSector);

            if (!myDnnUser.IsInRole("Registered Users"))
            {
                var oDnnRoleController = new RoleController();

                RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "Registered Users");
                oDnnRoleController.AddUserRole(this.PortalId, myDnnUser.UserID, oCurrentRole.RoleID,
                                               System.DateTime.Now.AddDays(-1),
                                               DotNetNuke.Common.Utilities.Null.NullDate);
            }

            PopulateControls();
            setControl("VIEW");
        }
    }