コード例 #1
0
        public ActionResult CompleteEntityProfile(ClientEntityCompleteProfileBinding model)
        {
            var userId = User.Identity.GetUserId();

            if (userId != model.UserID)
            {
                ModelState.AddModelError("", "Invalid user id provided");
            }
            if (ModelState.IsValid)
            {
                ClientRegistration clientRegistration = new ClientRegistration()
                {
                    ClientNumber = model.UserID,
                    Address      = model.line1 + " " + model.line2 + " " + model.line3 + " " + model.Suburb + " " + model.State + " " + model.Country + " " + model.PostCode,
                    EntityName   = model.EntityName,
                    EntityType   = model.EntityType,
                    ABN          = model.ABN,
                    ACN          = model.ACN,
                    Phone        = model.Phone,
                    Fax          = model.Fax
                };

                edisRopo.UpdateClientSync(clientRegistration);


                #region create risk profile if present
                if (model.riskProfile != null)
                {
                    var         riskProfile = model.riskProfile;
                    RiskProfile profile     = new RiskProfile {
                        CapitalLossAttitude    = riskProfile.capitalLossAttitude,
                        ClientID               = edisRopo.GetClientSync(model.UserID, DateTime.Now).Id,
                        Comments               = riskProfile.comments,
                        DateCreated            = DateTime.Now,
                        DateModified           = DateTime.Now,
                        IncomeSource           = riskProfile.incomeSource,
                        InvestmentKnowledge    = riskProfile.investmentKnowledge,
                        InvestmentObjective1   = riskProfile.investmentObjective1,
                        InvestmentObjective2   = riskProfile.investmentObjective2,
                        InvestmentObjective3   = riskProfile.investmentObjective3,
                        InvestmentProfile      = riskProfile.investmentProfile,
                        InvestmentTimeHorizon  = riskProfile.investmentTimeHorizon,
                        LongTermGoal1          = riskProfile.longTermGoal1,
                        LongTermGoal2          = riskProfile.longTermGoal2,
                        LongTermGoal3          = riskProfile.longTermGoal3,
                        MedTermGoal1           = riskProfile.medTermGoal1,
                        MedTermGoal2           = riskProfile.medTermGoal2,
                        MedTermGoal3           = riskProfile.medTermGoal3,
                        RetirementAge          = string.IsNullOrEmpty(riskProfile.retirementAge) ? (int?)null : Convert.ToInt32(riskProfile.retirementAge),
                        RetirementIncome       = riskProfile.retirementIncome,
                        RiskAttitude           = riskProfile.riskAttitude,
                        ShortTermAssetPercent  = riskProfile.shortTermAssetPercent,
                        ShortTermEquityPercent = riskProfile.shortTermEquityPercent,
                        ShortTermGoal1         = riskProfile.shortTermGoal1,
                        ShortTermGoal2         = riskProfile.shortTermGoal2,
                        ShortTermGoal3         = riskProfile.shortTermGoal3,
                        ShortTermTrading       = riskProfile.shortTermTrading,
                        //riskLevel = (int)RiskLevels.NotSet
                    };
                    if (edisRopo.getRiskProfileForClient(edisRopo.GetClientSync(model.UserID, DateTime.Now).Id) != null)
                    {
                        edisRopo.UpdateRiskProfile(profile);
                    }
                    else
                    {
                        edisRopo.CreateRiskProfileForClient(profile);
                    }
                }
                #endregion

                UserManager.RemoveFromRole(userId, AuthorizationRoles.Role_Preclient);
                UserManager.AddToRole(userId, AuthorizationRoles.Role_Client);

                //redirect to client dashboard here
                //return RedirectToAction("Index", "Client");
                //TempData["message"] = "Your profile has been successfully updated";
                //return JavaScript("document.location.replace('" + Url.Action("showMessage") + "');");
                return(JavaScript("document.location.replace('" + Url.Action("Index", "Client") + "');"));
            }
            else
            {
                return(PartialView(model));
            }
        }
コード例 #2
0
        public PartialViewResult CompleteEntityProfile()
        {
            var userId      = User.Identity.GetUserId();
            var client      = edisRopo.GetClientSync(userId, DateTime.Now);
            var riskProfile = edisRopo.getRiskProfileForClient(client.Id);
            RiskProfileBindingModel riskModel = null;

            if (riskProfile != null)
            {
                riskModel = new RiskProfileBindingModel {
                    capitalLossAttitude    = riskProfile.CapitalLossAttitude,
                    clientId               = riskProfile.ClientID,
                    comments               = riskProfile.Comments,
                    incomeSource           = riskProfile.IncomeSource,
                    retirementAge          = riskProfile.RetirementAge.ToString(),
                    riskAttitude           = riskProfile.RiskAttitude,
                    shortTermEquityPercent = riskProfile.ShortTermEquityPercent,
                    shortTermAssetPercent  = riskProfile.ShortTermAssetPercent,
                    investmentKnowledge    = riskProfile.InvestmentKnowledge,
                    investmentObjective1   = riskProfile.InvestmentObjective1,
                    investmentObjective2   = riskProfile.InvestmentObjective2,
                    investmentObjective3   = riskProfile.InvestmentObjective3,
                    investmentProfile      = riskProfile.InvestmentProfile,
                    investmentTimeHorizon  = riskProfile.InvestmentTimeHorizon,
                    longTermGoal1          = riskProfile.LongTermGoal1,
                    longTermGoal2          = riskProfile.LongTermGoal2,
                    longTermGoal3          = riskProfile.LongTermGoal3,
                    medTermGoal1           = riskProfile.MedTermGoal1,
                    medTermGoal2           = riskProfile.MedTermGoal2,
                    medTermGoal3           = riskProfile.MedTermGoal3,
                    profileId              = riskProfile.RiskProfileID,
                    retirementIncome       = riskProfile.RetirementIncome,
                    shortTermGoal1         = riskProfile.ShortTermGoal1,
                    shortTermGoal2         = riskProfile.ShortTermGoal2,
                    shortTermGoal3         = riskProfile.ShortTermGoal3,
                    shortTermTrading       = riskProfile.ShortTermTrading
                };
            }

            ClientEntityCompleteProfileBinding model = new ClientEntityCompleteProfileBinding {
                UserID      = userId,
                EntityName  = client.EntityName,
                EntityType  = client.EntityType,
                Phone       = client.Phone,
                ABN         = client.ABN,
                ACN         = client.ACN,
                Fax         = client.Fax,
                riskProfile = riskModel
            };


            if (!string.IsNullOrEmpty(client.Address))
            {
                string[] address = client.Address.Split(' ');
                model.PostCode = address[address.Length - 1];
                model.Country  = address[address.Length - 2];
                model.State    = address[address.Length - 3];
                model.Suburb   = address[address.Length - 4];
                for (int i = 0; i < address.Length - 4; i++)
                {
                    model.line1 += address[i] + " ";
                }
            }

            return(PartialView(model));
        }