예제 #1
0
    private void SaveFranchisor()
    {
        OtherDAL otherDal = new OtherDAL();
        EZip     objczip;

        objczip = otherDal.CheckCityZip(txtCity.Text, txtzip1.Text, ddlState.SelectedValue);

        if (objczip.CityID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('City name entered for contact address is not valid.');", true);
            return;
        }
        else if (objczip.CityID > 0 && objczip.ZipID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('Zip Code entered for contact address, corresponding to its city name, is not valid.');", true);
            return;
        }

        EFranchisorUser franchisoruser = new EFranchisorUser();
        var             address        = new Falcon.Entity.Other.EAddress();
        var             user           = new Falcon.Entity.Other.EUser();
        // format phone no.
        CommonCode objCommonCode = new CommonCode();


        franchisoruser.Active = true;

        address.Address1       = txtaddress1.Text;
        address.Address2       = txtAddress2.Text;
        address.CityID         = objczip.CityID;
        address.StateID        = Convert.ToInt32(ddlState.SelectedValue);
        address.CountryID      = Convert.ToInt32(hfCountryID.Value);
        address.ZipID          = objczip.ZipID;
        user.FirstName         = txtfname.Text;
        user.MiddleName        = txtMiddleName.Text;
        user.LastName          = txtlname.Text;
        user.SSN               = txtSSN.Text;
        user.DOB               = Convert.ToDateTime(txtDOB.Text).ToString();
        user.PhoneHome         = objCommonCode.FormatPhoneNumber(txtphonehome.Text);
        user.PhoneOffice       = objCommonCode.FormatPhoneNumber(txtphoneother.Text);
        user.PhoneCell         = objCommonCode.FormatPhoneNumber(txtphonecell.Text);
        user.EMail1            = txtEmail1.Text;
        user.EMail2            = txtEmail2.Text;
        franchisoruser.User    = user;
        franchisoruser.Address = address;
        Int64 returnresult;

        var currentSession = IoC.Resolve <ISessionContext>().UserSession;


        franchisoruser.ShellDescription = txtabtmself.Text;

        FranchisorDAL franchisorDAL = new FranchisorDAL();

        if (ViewState["IsEdit"].ToString() != string.Empty)
        {
            franchisoruser.User.UserID = Convert.ToInt32(currentSession.UserId);


            returnresult = franchisorDAL.SaveFranchisorUser(franchisoruser, Convert.ToInt32(EOperationMode.Update),
                                                            currentSession.CurrentOrganizationRole.OrganizationId.ToString());
            if (returnresult == 0)
            {
                returnresult = 9999991;
            }

            if (txtPassword.Text.Length > 0)
            {
                var userLoginService = IoC.Resolve <IUserLoginService>();
                userLoginService.ResetPassword(Convert.ToInt32(currentSession.UserId), txtPassword.Text, false, currentSession.CurrentOrganizationRole.OrganizationRoleUserId, false);
            }
            Response.RedirectUser(ResolveUrl("~/App/Franchisor/ProfilePage.aspx"));
        }
        else
        {
            returnresult = franchisorDAL.SaveFranchisorUser(franchisoruser, Convert.ToInt32(EOperationMode.Insert),
                                                            currentSession.CurrentOrganizationRole.OrganizationId.ToString());
            if (returnresult == 0)
            {
                returnresult = 9999990;
            }
        }
    }