Exemplo n.º 1
0
        //public async Task SaveAsync()
        //{
        //    await db.SaveChangesAsync();
        //}

        //#region helpers
        //private void AddAdviserProfile_Complete(AdviserRegistrationBindingModel model)
        //{
        //    CommonReferenceDataRepository comRepo = new CommonReferenceDataRepository(db);
        //    #region adviser_details
        //    Adviser adviserDetails = new Adviser()
        //    {
        //        AdviserId = model.adviserUserId,
        //        ABNACN = model.ABN,
        //        CompanyName = model.companyName,
        //        Country = model.country,
        //        AddressLn1 = model.addressLine1,
        //        AddressLn2 = model.addressLine2,
        //        AddressLn3 = model.addressLine3,
        //        CreatedOn = DateTime.Now,
        //        CurrentTitle = model.currentPositionTitle,
        //        ExperienceStartDate = model.industryExperienceStartDate,
        //        Fax = model.businessFax,
        //        FirstName = model.firstName,
        //        Gender = model.gender,
        //        LastName = model.lastName,
        //        LastUpdate = DateTime.Now,
        //        Lat = GoogleGeoService.GetCoordinatesLat(model.addressLine1 + " "
        //        + model.addressLine2 + " " + model.addressLine3 + " "
        //        + model.state + " " + model.country),
        //        Lng = GoogleGeoService.GetCoordinatesLng(model.addressLine1 + " "
        //        + model.addressLine2 + " " + model.addressLine3 + " "
        //        + model.state + " " + model.country),
        //        MiddleName = model.middleName,
        //        Mobile = model.businessMobile,
        //        Phone = model.businessPhone,
        //        PostCode = model.postCode,
        //        State = model.state,
        //        Suburb = model.suburb,
        //        Title = model.title,
        //        VerifiedId = BusinessLayerParameters.verificationStatus_NotVerified,
        //    };

        //    db.Advisers.Add(adviserDetails);
        //    #endregion
        //    #region adviser_dealerGroupDetails
        //    Adviser_DealerGroupDetails adviserDealerGroupDetails = new Adviser_DealerGroupDetails()
        //    {
        //        AddressLn1 = model.dealerGroup_addressLine1,
        //        AddressLn2 = model.dealerGroup_addressLine2,
        //        AddressLn3 = model.dealerGroup_addressLine3,
        //        AFSL = model.asfl,
        //        AuthorisedRepNumber = model.authorizedRepresentativeNumber,
        //        Country = model.dealerGroup_country,
        //        DealerGroupName = model.dealerGroupName,
        //        HasDerivativesLicense = model.dealerGroupHasDerivativesLicense ? 1 : 0,
        //        IsAuthorisedRep = model.isAuthorizedRepresentative ? 1 : 0,
        //        LastUpdated = DateTime.Now,
        //        PostCode = model.dealerGroup_postCode,
        //        State = model.dealerGroup_state,
        //        Suburb = model.dealerGroup_suburb,
        //        UserId = model.adviserUserId
        //    };
        //    db.Adviser_DealerGroupDetails.Add(adviserDealerGroupDetails);
        //    #endregion
        //    #region adviser_managementDetails
        //    Adviser_ManagementDetails adviserManagementDetails = new Adviser_ManagementDetails()
        //    {
        //        LastUpdated = DateTime.Now,
        //        TotalManagedInvestments = getDoubleFromProperty(model.totalInvestmentUndermanagement),
        //        TotalDirectAustralianEquities = getDoubleFromProperty(model.totalDirectAustralianEquitiesUnderManagement),
        //        TotalDirectInternational = getDoubleFromProperty(model.totalDirectInterantionalEquitiesUnderManagement),
        //        TotalFixedInterest = getDoubleFromProperty(model.totalDirectFixedInterestUnderManagement),
        //        TotalLendingBook = getDoubleFromProperty(model.totalDirectLendingBookInterestUnderManagement),
        //        UserId = model.adviserUserId,
        //        TotalAssets = getDoubleFromProperty(model.totalAssetUnderManagement),
        //        ApproxClientNumbersId = model.numberOfClientsId
        //    };
        //    db.Adviser_ManagementDetails.Add(adviserManagementDetails);
        //    #endregion
        //    #region adviser_educations
        //    if (model.educations != null)
        //    {
        //        foreach (var item in model.educations)
        //        {

        //            var level = comRepo.GetAllEducationLevels().SingleOrDefault(ed => ed.EducationLevelsId == item.educationLevelId);
        //            Adviser_Education education = new Adviser_Education()
        //            {
        //                CourseName = item.courseTitle,
        //                CurrentlyStudying = item.courseStatus ? 1 : 0,
        //                EducationLevels = level != null ? level.EducationLevels : "",
        //                Institution = item.institution,
        //                LastUpdated = DateTime.Now,
        //                UserId = model.adviserUserId,
        //            };
        //            db.Adviser_Education.Add(education);

        //        }
        //    }

        //    #endregion
        //    #region adviser_professionalType
        //    Adviser_ProfessionalType professionalType = new Adviser_ProfessionalType()
        //    {
        //        ProfessionTypeId = string.IsNullOrEmpty(model.professiontypeId) ? (int?)null : Convert.ToInt32(model.professiontypeId),
        //        UserId = model.adviserUserId
        //    };
        //    db.Adviser_ProfessionalType.Add(professionalType);
        //    #endregion
        //    #region adviser_serviceProviding
        //    if (model.services != null)
        //    {
        //        foreach (var group in model.services)
        //        {

        //            foreach (var item in group.services)
        //            {
        //                Adviser_ServicesProviding service = new Adviser_ServicesProviding()
        //                {
        //                    DateAdded = DateTime.Now,
        //                    SubServiceId = item.serviceId,
        //                    SubServiceProvideYesNo = item.providing ? "Yes" : "No",
        //                    UserId = model.adviserUserId
        //                };
        //                db.Adviser_ServicesProviding.Add(service);
        //            }
        //        }
        //    }
        //    #endregion
        //    #region adviser Newsletter
        //    foreach (var item in model.newsLetterServices)
        //    {
        //        User_NewsletterServices newsletter = new User_NewsletterServices()
        //        {
        //            IsSubscribed = item.selected ? "True" : "False",
        //            LastUpdated = DateTime.Now,
        //            NewsletterServicesId = item.newsLetterServiceId,
        //            UserId = model.adviserUserId
        //        };
        //        db.User_NewsletterServices.Add(newsletter);
        //    }
        //    #endregion
        //    #region adviser fees and commissions
        //    foreach (var item in model.commissionsAndFees)
        //    {

        //        Adviser_CommissionsAndFees fc = new Adviser_CommissionsAndFees()
        //        {
        //            CommissionsAndFeesId = item.id,
        //            LastUpdated = DateTime.Now,
        //            UserId = model.adviserUserId,
        //            YesNoNA = item.selected ? 1 : 0
        //        };
        //        db.Adviser_CommissionsAndFees.Add(fc);
        //    }

        //    Adviser_CommissionsAndFees rfc = new Adviser_CommissionsAndFees()
        //    {
        //        CommissionsAndFeesId = BusinessLayerParameters.feesAndCommissions_RemunerationType,
        //        YesNoNA = model.remunerationMethodSpecified ? 1 : 0,
        //        UserId = model.adviserUserId,
        //        LastUpdated = DateTime.Now,
        //        CommissionDescription = model.remunerationMethod
        //    };
        //    db.Adviser_CommissionsAndFees.Add(rfc);
        //    #endregion
        //    #region adviser target clients
        //    Adviser_TargetClients target = new Adviser_TargetClients()
        //    {
        //        AnnualIncomeLevelsId = model.annualIncomeLevelId,
        //        InvestibleAssetsLevelId = model.investibleAssetLevel,
        //        LastUpdated = DateTime.Now,
        //        TotalAssetsLevelId = model.totalAssetLevelId,
        //        UserId = model.adviserUserId
        //    };
        //    db.Adviser_TargetClients.Add(target);


            #endregion
        //}
        private void UpdateAdviserProfile_Complete(AdviserRegistrationBindingModel model)
        {
            var userid = model.adviserUserId;
            #region adviser details
            var adviserDetails = db.Advisers.FirstOrDefault(ad => ad.AdviserId == userid);
            adviserDetails.ABNACN = model.ABN;
            adviserDetails.CompanyName = model.companyName;
            adviserDetails.Country = model.country;
            adviserDetails.AddressLn1 = model.addressLine1;
            adviserDetails.AddressLn2 = model.addressLine2;
            adviserDetails.AddressLn3 = model.addressLine3;
            adviserDetails.CurrentTitle = model.currentPositionTitle;
            adviserDetails.ExperienceStartDate = model.industryExperienceStartDate;
            adviserDetails.Fax = model.businessFax;
            adviserDetails.Gender = model.gender;
            adviserDetails.LastName = model.lastName;
            adviserDetails.FirstName = model.firstName;
            adviserDetails.LastUpdate = DateTime.Now;
            adviserDetails.Lat = GoogleGeoService.GetCoordinatesLat(model.addressLine1 + " "
            + model.addressLine2 + " " + model.addressLine3 + " "
            + model.state + " " + model.country);
            adviserDetails.Lng = GoogleGeoService.GetCoordinatesLng(model.addressLine1 + " "
            + model.addressLine2 + " " + model.addressLine3 + " "
            + model.state + " " + model.country);
            adviserDetails.MiddleName = model.middleName;
            adviserDetails.Mobile = model.businessMobile;
            adviserDetails.Phone = model.businessPhone;
            adviserDetails.PostCode = model.postCode;
            adviserDetails.State = model.state;
            adviserDetails.Suburb = model.suburb;
            adviserDetails.Title = model.title;

            #endregion
            //#region adviser_dealer_group
            //var dealership = db.Adviser_DealerGroupDetails.FirstOrDefault(d => d.UserId == userid);
            //dealership.AddressLn1 = model.dealerGroup_addressLine1;
            //dealership.AddressLn2 = model.dealerGroup_addressLine2;
            //dealership.AddressLn3 = model.dealerGroup_addressLine3;
            //dealership.AFSL = model.asfl;
            //dealership.AuthorisedRepNumber = model.authorizedRepresentativeNumber;
            //dealership.Country = model.dealerGroup_country;
            //dealership.DealerGroupName = model.dealerGroupName;
            //dealership.HasDerivativesLicense = model.dealerGroupHasDerivativesLicense ? 1 : 0;
            //dealership.IsAuthorisedRep = model.isAuthorizedRepresentative ? 1 : 0;
            //dealership.LastUpdated = DateTime.Now;
            //dealership.PostCode = model.dealerGroup_postCode;
            //dealership.State = model.dealerGroup_state;
            //dealership.Suburb = model.dealerGroup_suburb;
            //#endregion
            //#region adviser management details
            //var managementDetail = db.Adviser_ManagementDetails.FirstOrDefault(m => m.UserId == userid);
            //managementDetail.LastUpdated = DateTime.Now;
            //managementDetail.TotalManagedInvestments = getDoubleFromProperty(model.totalInvestmentUndermanagement);
            //managementDetail.TotalDirectAustralianEquities = getDoubleFromProperty(model.totalDirectAustralianEquitiesUnderManagement);
            //managementDetail.TotalDirectInternational = getDoubleFromProperty(model.totalDirectInterantionalEquitiesUnderManagement);
            //managementDetail.TotalFixedInterest = getDoubleFromProperty(model.totalDirectFixedInterestUnderManagement);
            //managementDetail.TotalLendingBook = getDoubleFromProperty(model.totalDirectLendingBookInterestUnderManagement);
            //managementDetail.TotalAssets = getDoubleFromProperty(model.totalAssetUnderManagement);
            //managementDetail.ApproxClientNumbersId = model.numberOfClientsId;
            //#endregion
            //#region educations
            ////remove all educations
            //var existingEducations = db.Adviser_Education.Where(ed => ed.UserId == userid);
            //db.Adviser_Education.RemoveRange(existingEducations);
            ////add new educations
            //if (model.educations != null)
            //{
            //    foreach (var item in model.educations)
            //    {
            //        var level = comRepo.GetAllEducationLevels().SingleOrDefault(ed => ed.EducationLevelsId == item.educationLevelId);
            //        Adviser_Education education = new Adviser_Education()
            //        {
            //            CourseName = item.courseTitle,
            //            CurrentlyStudying = item.courseStatus ? 1 : 0,
            //            EducationLevels = level != null ? level.EducationLevels : "",
            //            Institution = item.institution,
            //            LastUpdated = DateTime.Now,
            //            UserId = userid,
            //        };
            //        db.Adviser_Education.Add(education);

            //    }
            //}
            //#endregion
            //#region professional Type
            //var professionalType = db.Adviser_ProfessionalType.FirstOrDefault(p => p.UserId == userid);
            //professionalType.ProfessionTypeId = string.IsNullOrEmpty(model.professiontypeId) ?
            //    (int?)null : Convert.ToInt32(model.professiontypeId);
            //#endregion
            //#region services provided
            ////remove existing services
            //var existingServices = db.Adviser_ServicesProviding.Where(s => s.UserId == userid);
            //db.Adviser_ServicesProviding.RemoveRange(existingServices);
            //if (model.services != null)
            //{
            //    foreach (var group in model.services)
            //    {

            //        foreach (var item in group.services)
            //        {
            //            Adviser_ServicesProviding service = new Adviser_ServicesProviding()
            //            {
            //                DateAdded = DateTime.Now,
            //                SubServiceId = item.serviceId,
            //                SubServiceProvideYesNo = item.providing ? "Yes" : "No",
            //                UserId = userid
            //            };
            //            db.Adviser_ServicesProviding.Add(service);
            //        }
            //    }
            //}
            //#endregion
            //#region newsletter
            ////remove existing newsletter settings
            //var existingNewsletter = db.User_NewsletterServices.Where(n => n.UserId == userid);
            //db.User_NewsletterServices.RemoveRange(existingNewsletter);
            ////add new ones
            //foreach (var item in model.newsLetterServices)
            //{
            //    User_NewsletterServices newsletter = new User_NewsletterServices()
            //    {
            //        IsSubscribed = item.selected ? "True" : "False",
            //        LastUpdated = DateTime.Now,
            //        NewsletterServicesId = item.newsLetterServiceId,
            //        UserId = userid
            //    };
            //    db.User_NewsletterServices.Add(newsletter);
            //}
            //#endregion
            //#region commission and fees
            ////remove all existing commissions and fees
            //var existingFees = db.Adviser_CommissionsAndFees.Where(c => c.UserId == userid);
            //db.Adviser_CommissionsAndFees.RemoveRange(existingFees);
            ////add new ones
            //foreach (var item in model.commissionsAndFees)
            //{

            //    Adviser_CommissionsAndFees fc = new Adviser_CommissionsAndFees()
            //    {
            //        CommissionsAndFeesId = item.id,
            //        LastUpdated = DateTime.Now,
            //        UserId = userid,
            //        YesNoNA = item.selected ? 1 : 0
            //    };
            //    db.Adviser_CommissionsAndFees.Add(fc);
            //}

            //Adviser_CommissionsAndFees rfc = new Adviser_CommissionsAndFees()
            //{
            //    CommissionsAndFeesId = BusinessLayerParameters.feesAndCommissions_RemunerationType,
            //    YesNoNA = model.remunerationMethodSpecified ? 1 : 0,
            //    UserId = userid,
            //    LastUpdated = DateTime.Now,
            //    CommissionDescription = model.remunerationMethod
            //};
            //db.Adviser_CommissionsAndFees.Add(rfc);
            //#endregion
            //#region target clients
            //var target = db.Adviser_TargetClients.FirstOrDefault(t => t.UserId == userid);
            //target.AnnualIncomeLevelsId = model.annualIncomeLevelId;
            //target.InvestibleAssetsLevelId = model.investibleAssetLevel;
            //target.LastUpdated = DateTime.Now;
            //target.TotalAssetsLevelId = model.totalAssetLevelId;
            //#endregion
        }
Exemplo n.º 2
0
        public ActionResult AdviserDetails(string id)
        {

            var adviser = db.Advisers.FirstOrDefault(a => a.AdviserNumber == id);
            //var adviser = edisRepo.GetAdviser(id, DateTime.Now).Result;
            if (adviser == null)
            {
                return HttpNotFound();
            }
            AdviserRegistrationBindingModel model = new AdviserRegistrationBindingModel { 
                ABN = adviser.ABNACN,
                addressLine1 = adviser.AddressLn1,
                addressLine2 = adviser.AddressLn2,
                addressLine3 = adviser.AddressLn3,
                adviserUserId = adviser.AdviserNumber,
                businessFax = adviser.Fax,
                businessMobile = adviser.Mobile,
                businessPhone = adviser.Phone,
                companyName = adviser.CompanyName,
                country = adviser.Country,
                currentPositionTitle = adviser.CurrentTitle,
                firstName = adviser.FirstName,
                gender = adviser.Gender,
                lastName = adviser.LastName,
                middleName = adviser.MiddleName,
                postCode = adviser.PostCode,
                industryExperienceStartDate = adviser.ExperienceStartDate,
                GeoString = NullableDoubleToString(adviser.Lat, null) + " " + NullableDoubleToString(adviser.Lng, null),

                dealerGroupName = adviser.GroupName,
                dealerGroup_addressLine1 = adviser.DAddressLine1,
                dealerGroup_addressLine2 = adviser.DAddressLine2,
                dealerGroup_addressLine3 = adviser.DAddressLine3,
                dealerGroup_country = adviser.DCountry,
                dealerGroup_postCode = adviser.DPostcode,
                dealerGroup_suburb = adviser.DSuburb,
                dealerGroup_state = adviser.DState,
                asfl = adviser.Asfl,
                dealerGroupHasDerivativesLicense = adviser.DealerGroupHasDerivativesLicense,
                isAuthorizedRepresentative = adviser.IsAuthorizedRepresentative,
                authorizedRepresentativeNumber = adviser.AuthorizedRepresentativeNumber,
                AnnualIncomeLevel = ((EDIS_DOMAIN.Enum.Enums.AnnualIncomeLevel)adviser.AnnualIncomeLevelId).ToString(),
                annualIncomeLevelId = adviser.AnnualIncomeLevelId,
                approximateNumberOfClients = adviser.ApproximateNumberOfClients,
                approxNumberOfClients = adviser.ApproximateNumberOfClients,
                investibleAssetLevel = adviser.InvestibleAssetLevel,
                InvestibleAssetLevelString = ((EDIS_DOMAIN.Enum.Enums.InvestibleAssetsLevel)adviser.InvestibleAssetLevel).ToString(),
                numberOfClientsId = adviser.NumberOfClientsId,
                professiontypeId = adviser.ProfessiontypeId,
                remunerationMethod = adviser.RemunerationMethod,
                remunerationMethodSpecified = adviser.RemunerationMethodSpecified,
                roleAndServicesSummary = adviser.RoleAndServicesSummary,
                state = adviser.State,
                suburb = adviser.Suburb,
                title = adviser.Title,
                TotalAssetLevel = adviser.TotalAssetLevel,
                totalAssetLevelId = adviser.TotalAssetLevelId,
                totalAssetUnderManagement = adviser.TotalAssetUnderManagement,
                totalDirectAustralianEquitiesUnderManagement = adviser.TotalDirectAustralianEquitiesUnderManagement,
                totalDirectFixedInterestUnderManagement = adviser.TotalDirectFixedInterestUnderManagement,
                totalDirectInterantionalEquitiesUnderManagement = adviser.TotalDirectInterantionalEquitiesUnderManagement,
                totalDirectLendingBookInterestUnderManagement = adviser.TotalDirectLendingBookInterestUnderManagement,
                totalInvestmentUndermanagement = adviser.TotalInvestmentUndermanagement
            };

            #region personal details
            


            #endregion
            #region target clients
            //var targetClient = db.Adviser_TargetClients.FirstOrDefault(t => t.UserId == id);

            //if (targetClient != null)
            //{
            //    if (targetClient.AnnualIncomeLevelsId.HasValue
            //        && comRepo.GetAllAnnualIncomeLevels().FirstOrDefault(a => a.AnnualIncomeLevelsId == targetClient.AnnualIncomeLevelsId.Value) != null)
            //    {
            //        model.AnnualIncomeLevel = comRepo.GetAllAnnualIncomeLevels()
            //            .FirstOrDefault(a => a.AnnualIncomeLevelsId == targetClient.AnnualIncomeLevelsId.Value).AnnualIncomeLevels;
            //    }

            //    if (targetClient.TotalAssetsLevelId.HasValue
            //        && comRepo.GetAllTotalAssetLevels().FirstOrDefault(t => t.TotalAssetsLevelId == targetClient.TotalAssetsLevelId.Value) != null)
            //    {
            //        model.TotalAssetLevel = comRepo.GetAllTotalAssetLevels()
            //            .FirstOrDefault(t => t.TotalAssetsLevelId == targetClient.TotalAssetsLevelId.Value).TotalAssetsLevel1;
            //    }

            //    if (targetClient.InvestibleAssetsLevelId.HasValue
            //        && comRepo.GetAllInvestibleAssetLevels().FirstOrDefault(t => t.InvestibleAssetsLevelId == targetClient.InvestibleAssetsLevelId.Value) != null)
            //    {
            //        model.InvestibleAssetLevelString = comRepo.GetAllInvestibleAssetLevels()
            //            .FirstOrDefault(t => t.InvestibleAssetsLevelId == targetClient.InvestibleAssetsLevelId.Value).InvestibleAssetsLevel1;
            //    }
            //}
            //#endregion
            //#region asset management details
            //var adviserManagementDetails = db.Adviser_ManagementDetails.FirstOrDefault(a => a.UserId == id);
            //if (adviserManagementDetails != null)
            //{
            //    if (adviserManagementDetails.ApproxClientNumbersId.HasValue
            //        && comRepo.GetApproxClientNumbers().FirstOrDefault(d => d.ApproxClientNumbersId == adviserManagementDetails.ApproxClientNumbersId.Value) != null)
            //    {
            //        model.approximateNumberOfClients = comRepo.GetApproxClientNumbers()
            //            .FirstOrDefault(d => d.ApproxClientNumbersId == adviserManagementDetails.ApproxClientNumbersId.Value).ApproxClientNumbers;
            //    }
            //    model.totalAssetUnderManagement = NullableDoubleToString(adviserManagementDetails.TotalAssets, "C0");
            //    model.totalDirectAustralianEquitiesUnderManagement = NullableDoubleToString(adviserManagementDetails.TotalDirectAustralianEquities, "C0");
            //    model.totalDirectFixedInterestUnderManagement = NullableDoubleToString(adviserManagementDetails.TotalFixedInterest, "C0");
            //    model.totalDirectInterantionalEquitiesUnderManagement = NullableDoubleToString(adviserManagementDetails.TotalDirectInternational, "C0");
            //    model.totalDirectLendingBookInterestUnderManagement = NullableDoubleToString(adviserManagementDetails.TotalLendingBook, "C0");
            //    model.totalInvestmentUndermanagement = NullableDoubleToString(adviserManagementDetails.TotalManagedInvestments, "C0");
            //}
            //#endregion
            //#region dealer group details
            //var dealerGroupDetails = db.Adviser_DealerGroupDetails.FirstOrDefault(d => d.UserId == id);
            //if (dealerGroupDetails != null)
            //{
            //    model.asfl = dealerGroupDetails.AFSL;
            //    model.authorizedRepresentativeNumber = dealerGroupDetails.AuthorisedRepNumber;
            //    model.dealerGroup_addressLine1 = dealerGroupDetails.AddressLn1;
            //    model.dealerGroup_addressLine2 = dealerGroupDetails.AddressLn2;
            //    model.dealerGroup_addressLine3 = dealerGroupDetails.AddressLn3;
            //    model.dealerGroup_country = dealerGroupDetails.Country;
            //    model.dealerGroup_postCode = dealerGroupDetails.PostCode;
            //    model.dealerGroup_state = dealerGroupDetails.State;
            //    model.dealerGroup_suburb = dealerGroupDetails.Suburb;
            //    model.dealerGroupHasDerivativesLicense = dealerGroupDetails.HasDerivativesLicense.HasValue && dealerGroupDetails.HasDerivativesLicense.Value == 1 ? true : false;
            //    model.dealerGroupName = dealerGroupDetails.DealerGroupName;
            //    model.isAuthorizedRepresentative = dealerGroupDetails.IsAuthorisedRep.HasValue && dealerGroupDetails.IsAuthorisedRep.Value == 1 ? true : false;
            //}
            //#endregion
            //#region services provided
            //var services = db.Adviser_ServicesProviding
            //    .Where(s => s.UserId == id && s.SubServiceProvideYesNo == "True")
            //    .Select(s => db.SubServices
            //        .Where(ss => ss.SubServiceId == s.SubServiceId)
            //        .FirstOrDefault() != null ?
            //        db.SubServices
            //        .Where(ss => ss.SubServiceId == s.SubServiceId).FirstOrDefault().SubServiceName : "")
            //    .ToList().ToArray();
            //model.ProvidedServicesString = String.Join(",", services);
            //#endregion
            //#region educations
            //model.educations = new List<EducationCreationModel>();
            //db.Adviser_Education.Where(ae => ae.UserId == id)
            //    .ToList()
            //    .ForEach(ed =>
            //    {
            //        model.educations.Add(new EducationCreationModel
            //        {
            //            courseStatus = ed.CurrentlyStudying == 1,
            //            courseTitle = ed.CourseName,
            //            institution = ed.Institution
            //        });
            //    });


            #endregion
            return View(model);

        }
 private void checkEducationList(AdviserRegistrationBindingModel model)
 {
     if (model.educations == null || model.educations.Count == 0)
     {
         ViewBag.numberOfEducations = 0;
     }
     else
     {
         ViewBag.numberOfEducations = model.educations.Count;
     }
 }
        public ActionResult AdviserProfile()
        {
            ViewBag.professTypes = cmRepo.GetAllProfessionTypes().Select(p => new SelectListItem
            {
                Text = p.ProfessionType1,
                Value = p.ProfessionTypeId.ToString()
            }).ToList();

            Adviser adviser = edisRepo.GetAdviserSync(User.Identity.GetUserId(), DateTime.Now);
            AdviserRegistrationBindingModel adviserModel = new AdviserRegistrationBindingModel
            {
                adviserUserId = adviser.Id,
                ABN = adviser.ABNACN,
                addressLine1 = adviser.AddressLn1,
                addressLine2 = adviser.AddressLn2,
                addressLine3 = adviser.AddressLn3,
                annualIncomeLevelId = adviser.AnnualIncomeLevelId,
                approximateNumberOfClients = adviser.ApproximateNumberOfClients,
                approxNumberOfClients = adviser.ApproximateNumberOfClients,
                asfl = adviser.Asfl,
                authorizedRepresentativeNumber = adviser.AuthorizedRepresentativeNumber,
                businessFax = adviser.BusinessFax,
                businessMobile = adviser.BusinessMobile,
                businessPhone = adviser.BusinessPhone,
                companyName = adviser.CompanyName,
                country = adviser.Country,
                currentPositionTitle = adviser.CurrentTitle,
                dealerGroup_addressLine1 = adviser.DAddressLine1,
                dealerGroup_addressLine2 = adviser.DAddressLine2,
                dealerGroup_addressLine3 = adviser.DAddressLine3,
                dealerGroup_country = adviser.DCountry,
                dealerGroup_postCode = adviser.DPostcode,
                dealerGroup_state = adviser.DState,
                dealerGroup_suburb = adviser.DSuburb,
                dealerGroupHasDerivativesLicense = adviser.DealerGroupHasDerivativesLicense,
                dealerGroupName = adviser.DealerGroupName,
                firstName = adviser.FirstName,
                gender = adviser.Gender,
                industryExperienceStartDate = adviser.IndustryExperienceStartDate,
                investibleAssetLevel = adviser.InvestibleAssetLevel,
                isAuthorizedRepresentative = adviser.IsAuthorizedRepresentative,
                lastName = adviser.LastName,
                middleName = adviser.MiddleName,
                postCode = adviser.PostCode,
                professiontypeId = adviser.ProfessiontypeId,
                remunerationMethod = adviser.RemunerationMethod,
                remunerationMethodSpecified = adviser.RemunerationMethodSpecified,
                roleAndServicesSummary = adviser.RoleAndServicesSummary,
                state = adviser.State,
                suburb = adviser.Suburb,
                title = adviser.Title,
                totalAssetLevelId = adviser.TotalAssetLevelId,
                totalAssetUnderManagement = adviser.TotalAssetUnderManagement,
                totalDirectAustralianEquitiesUnderManagement = adviser.TotalDirectAustralianEquitiesUnderManagement,
                totalDirectFixedInterestUnderManagement = adviser.TotalDirectFixedInterestUnderManagement,
                totalDirectInterantionalEquitiesUnderManagement = adviser.TotalDirectInterantionalEquitiesUnderManagement,
                totalDirectLendingBookInterestUnderManagement = adviser.TotalDirectLendingBookInterestUnderManagement,
                totalInvestmentUndermanagement = adviser.TotalInvestmentUndermanagement,
                AnnualIncomeLevel = ((EDIS_DOMAIN.Enum.Enums.AnnualIncomeLevel)adviser.AnnualIncomeLevelId).ToString(),
                numberOfClientsId = adviser.NumberOfClientsId,
                InvestibleAssetLevelString = adviser.InvestibleAssetLevel.ToString(),
                TotalAssetLevel = ((EDIS_DOMAIN.Enum.Enums.TotalAssetLevels)adviser.TotalAssetLevelId).ToString(),
            };

            List<NewsletterServiceModel> newsModelList = new List<NewsletterServiceModel>();
            foreach (var news in cmRepo.GetNewsletterService())
            {
                if (adviser.NewsLetterServiceId == news.NewsletterServicesId)
                {
                    newsModelList.Add(new NewsletterServiceModel
                    {
                        newsLetterServiceId = news.NewsletterServicesId,
                        serviceName = news.NewsletterServices,
                        selected = true,
                    });
                }
                else
                {
                    newsModelList.Add(new NewsletterServiceModel
                    {
                        newsLetterServiceId = news.NewsletterServicesId,
                        serviceName = news.NewsletterServices,
                        selected = false,
                    });

                }
            }
            adviserModel.newsLetterServices = newsModelList;

            #region add education level select drop down list
            List<SelectListItem> educationLevelSelect = new List<SelectListItem>();
            educationLevelSelect.Add(new SelectListItem()
            {
                Text = "Please select",
                Value = ""
            });
            cmRepo.GetAllEducationLevels().ToList().ForEach(level =>
            {
                SelectListItem item = new SelectListItem();
                item.Text = level.EducationLevels;
                item.Value = level.EducationLevelsId.ToString();
            });
            ViewBag.educationLevelSelect = educationLevelSelect;

            //generate number of education viewbag details
            checkEducationList(adviserModel);

            #endregion

            return View(adviserModel);
        }
        public ActionResult Create(AdviserRegistrationBindingModel model)
        {
            ViewBag.professTypes = cmRepo.GetAllProfessionTypes().Select(p => new SelectListItem
            {
                Text = p.ProfessionType1,
                Value = p.ProfessionTypeId.ToString()
            }).ToList();

            var allErrors = ModelState.Values.Where(v => v.Errors.Count > 0).ToList();
            if (ModelState.IsValid)
            {
                Adviser adviser = new Adviser(edisRepo)
                {
                    AdviserNumber = User.Identity.GetUserId(),
                    ABNACN = model.ABN,
                    CompanyName = model.companyName,
                    Country = model.country,
                    AddressLn1 = model.addressLine1,
                    AddressLn2 = model.addressLine2,
                    AddressLn3 = model.addressLine3,
                    CreatedOn = DateTime.Now,
                    CurrentTitle = model.currentPositionTitle,
                    ExperienceStartDate = model.industryExperienceStartDate,
                    Fax = model.businessFax,
                    FirstName = model.firstName,
                    Gender = model.gender,
                    LastName = model.lastName,
                    RoleAndServicesSummary = model.roleAndServicesSummary,
                    GroupName = model.dealerGroupName,
                    LastUpdate = DateTime.Now,
                    Lat = new GoogleGeoService(model.addressLine1 + " "
                    + model.addressLine2 + " " + model.addressLine3 + " " + model.suburb + " "
                    + model.state + " " + model.country).GetCoordinatesLat(),
                    Lng = new GoogleGeoService(model.addressLine1 + " "
                    + model.addressLine2 + " " + model.addressLine3 + " " + model.suburb + " "
                    + model.state + " " + model.country).GetCoordinatesLng(),
                    MiddleName = model.middleName,
                    Mobile = model.businessMobile,
                    Phone = model.businessPhone,
                    PostCode = model.postCode,
                    State = model.state,
                    Suburb = model.suburb,
                    Title = model.title,
                    VerifiedId = BusinessLayerParameters.verificationStatus_NotVerified,

                    IndustryExperienceStartDate = model.industryExperienceStartDate,
                    BusinessPhone = model.businessPhone,
                    BusinessMobile = model.businessMobile,
                    BusinessFax = model.businessFax,

                    DAddressLine1 = model.dealerGroup_addressLine1,
                    DAddressLine2 = model.dealerGroup_addressLine2,
                    DAddressLine3 = model.dealerGroup_addressLine3,
                    DPostcode = model.dealerGroup_postCode,
                    DState = model.dealerGroup_state,
                    DSuburb = model.dealerGroup_suburb,
                    DCountry = model.dealerGroup_country,
                    Asfl = model.asfl,
                    AuthorizedRepresentativeNumber = model.authorizedRepresentativeNumber,
                    DealerGroupName = model.dealerGroupName,
                    DealerGroupHasDerivativesLicense = model.dealerGroupHasDerivativesLicense ? true : false,
                    IsAuthorizedRepresentative = model.isAuthorizedRepresentative ? true : false,

                    TotalAssetUnderManagement = model.totalAssetUnderManagement,
                    TotalInvestmentUndermanagement = model.totalInvestmentUndermanagement,
                    TotalDirectAustralianEquitiesUnderManagement = model.totalDirectAustralianEquitiesUnderManagement,
                    TotalDirectInterantionalEquitiesUnderManagement = model.totalDirectInterantionalEquitiesUnderManagement,
                    TotalDirectFixedInterestUnderManagement = model.totalDirectFixedInterestUnderManagement,
                    TotalDirectLendingBookInterestUnderManagement = model.totalDirectLendingBookInterestUnderManagement,
                    ApproximateNumberOfClients = model.approximateNumberOfClients,

                    ProfessiontypeId = model.professiontypeId,
                    RemunerationMethodSpecified = model.remunerationMethodSpecified,
                    RemunerationMethod = model.remunerationMethod,
                    NumberOfClientsId = model.numberOfClientsId,
                    AnnualIncomeLevelId = model.annualIncomeLevelId,
                    InvestibleAssetLevel = model.investibleAssetLevel,
                    TotalAssetLevel = ((EDIS_DOMAIN.Enum.Enums.TotalAssetLevels)model.totalAssetLevelId).ToString(),
                    TotalAssetLevelId = model.totalAssetLevelId,

                };

                if (model.educations != null && model.educations.Count != 0)
                {
                    adviser.Institution = model.educations[0].institution;
                    adviser.CourseTitle = model.educations[0].courseTitle;
                    adviser.CourseStatus = model.educations[0].courseStatus;
                    adviser.EducationLevelId = model.educations[0].educationLevelId;
                }

                if (edisRepo.CreateAdviserSync(adviser) != null)
                {
                    TempData["success"] = "Profile has been updated";
                }
                else
                {
                    TempData["error"] = "Profile update failed. Please try again.";
                }

            }

            checkEducationList(model);
            return View(model);
        }
        public ActionResult Create()
        {
            //Adviser adviser = edisRepo.CreateAdviser("First Name", "Last Name", User.Identity.GetUserId()).Result;

            AdviserRegistrationBindingModel adviserModel = new AdviserRegistrationBindingModel();

            adviserModel.adviserUserId = User.Identity.GetUserId();

            ViewBag.professTypes = cmRepo.GetAllProfessionTypes().Select(p => new SelectListItem
            {
                Text = p.ProfessionType1,
                Value = p.ProfessionTypeId.ToString()
            }).ToList();

            #region add education level select drop down list
            List<SelectListItem> educationLevelSelect = new List<SelectListItem>();
            educationLevelSelect.Add(new SelectListItem()
            {
                Text = "Please select",
                Value = ""
            });
            cmRepo.GetAllEducationLevels().ToList().ForEach(level =>
            {
                SelectListItem item = new SelectListItem();
                item.Text = level.EducationLevels;
                item.Value = level.EducationLevelsId.ToString();
            });
            ViewBag.educationLevelSelect = educationLevelSelect;

            //generate number of education viewbag details
            checkEducationList(adviserModel);

            #endregion

            List<NewsletterServiceModel> newsModelList = new List<NewsletterServiceModel>();
            foreach (var news in cmRepo.GetNewsletterService())
            {
                newsModelList.Add(new NewsletterServiceModel
                {
                    newsLetterServiceId = news.NewsletterServicesId,
                    serviceName = news.NewsletterServices
                });
            }

            adviserModel.newsLetterServices = newsModelList;

            return View(adviserModel);

            //AdviserRegistrationBindingModel model = new AdviserRegistrationBindingModel();

            //var adviserId = User.Identity.GetUserId();

            //model.adviserUserId = adviserId;

            //Adviser adviser = edisRepo.GetAdviser(User.Identity.GetUserId(), DateTime.Now).Result;

            //if (adviser != null)
            //{
            //    model.adviserUserId = adviserId;
            //    model.ABN = adviser.ABNACN;
            //    model.addressLine1 = adviser.AddressLn1;
            //    model.addressLine2 = adviser.AddressLn2;
            //    model.addressLine3 = adviser.AddressLn3;
            //    model.businessFax = adviser.Fax;
            //    model.businessMobile = adviser.Mobile;
            //    model.businessPhone = adviser.Phone;
            //    model.companyName = adviser.CompanyName;
            //    model.country = adviser.Country;
            //    model.currentPositionTitle = adviser.CurrentTitle;
            //    model.firstName = adviser.FirstName;
            //    model.gender = adviser.Gender;
            //    model.industryExperienceStartDate = adviser.ExperienceStartDate;
            //    model.lastName = adviser.LastName;
            //    model.middleName = adviser.MiddleName;
            //    model.postCode = adviser.PostCode;
            //    model.state = adviser.State;
            //    model.suburb = adviser.Suburb;
            //    model.title = adviser.Title;
            //}

            //AdviserRegistrationBindingModel model = adviserRepo.GetAdviserProfile_Complete(User.Identity.GetUserId());

            //#region add education level select drop down list
            //List<SelectListItem> educationLevelSelect = new List<SelectListItem>();
            //educationLevelSelect.Add(new SelectListItem()
            //{
            //    Text = "Please select",
            //    Value = ""
            //});
            //cmRepo.GetAllEducationLevels().ToList().ForEach(level =>
            //{
            //    SelectListItem item = new SelectListItem();
            //    item.Text = level.EducationLevels;
            //    item.Value = level.EducationLevelsId.ToString();
            //});
            //ViewBag.educationLevelSelect = educationLevelSelect;

            ////generate number of education viewbag details
            //checkEducationList(model);

            //#endregion

            //return View(model);
        }