/// <summary>
        /// Authenticate a user by email address.
        /// </summary>
        /// <param name="emailAddress"></param>
        /// <returns></returns>
        private bool AuthenticateUser(string emailAddress)
        {
            // check user exist in the JXT Next database
            Telerik.Sitefinity.Security.Model.User existingUser = SitefinityHelper.GetUserByEmail(emailAddress);
            var memberResponse = _blConnector.GetMemberByEmail(emailAddress);

            if (memberResponse.Member == null)
            {
                UserProfileManager userProfileManager = UserProfileManager.GetManager();
                UserProfile        profile            = userProfileManager.GetUserProfile(existingUser.Id, typeof(SitefinityProfile).FullName);
                var fName = Telerik.Sitefinity.Model.DataExtensions.GetValue(profile, "FirstName");
                var lName = Telerik.Sitefinity.Model.DataExtensions.GetValue(profile, "LastName");
                JXTNext_MemberRegister memberReg = new JXTNext_MemberRegister
                {
                    Email     = emailAddress,
                    FirstName = fName.ToString(),
                    LastName  = lName.ToString(),
                    Password  = existingUser.Password
                };

                if (_blConnector.MemberRegister(memberReg, out string errorMessage))
                {
                    Log.Write("User created JXT next DB" + existingUser.Email, ConfigurationPolicy.ErrorLog);
                }
            }
            // end of the code for the user check in the JXT Next DB
            var userManager = UserManager.GetManager();

            SecurityManager.AuthenticateUser(userManager.Provider.Name, emailAddress, false, out User user);

            return(user != null);
        }
Exemple #2
0
        public ActionResult ViewResults(int id)
        {
            JobAlertViewModel jobAlertDetails = _jobAlertService.GetMemeberJobAlert(id).jobAlertViewModelData;
            string            resultsPageUrl  = SitefinityHelper.GetPageUrl(this.ResultsPageId);

            return(Redirect(resultsPageUrl + "?" + ToQueryString(jobAlertDetails)));
        }
        /// <summary>
        /// Create user from the LinkedIn profile data.
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        private bool CreateUserFromLinkedInProfileData(string accessToken)
        {
            // get the email address from the profile
            var emailAddress = LinkedInHelper.GetProfileEmailAddress(accessToken);

            if (string.IsNullOrEmpty(emailAddress))
            {
                Log.Write("LinkedIn: Email address not present in the response.");

                return(false);
            }

            // if an account already exist then authenticate
            var existingUser = SitefinityHelper.GetUserByEmail(emailAddress);

            if (existingUser != null)
            {
                if (!AuthenticateUser(emailAddress))
                {
                    Log.Write("LinkedIn: Unable to authenticate user using the email address.");

                    return(false);
                }

                return(true);
            }

            // at this point create a new account

            var profile = LinkedInHelper.GetProfile(accessToken);

            var membershipCreateStatus = SitefinityHelper.CreateUser(
                emailAddress,
                System.Web.Security.Membership.GeneratePassword(12, 2),
                profile.FirstName,
                profile.LastName,
                emailAddress,
                null,
                null,
                null,
                true,
                true
                );

            if (membershipCreateStatus != MembershipCreateStatus.Success)
            {
                Log.Write("LinkedIn: Unable to create user account.");

                return(false);
            }

            if (!AuthenticateUser(emailAddress))
            {
                Log.Write("LinkedIn: Unable to authenticate user using the email address after registration.");

                return(false);
            }

            return(true);
        }
Exemple #4
0
        public ActionResult Create(CreateAsJobAlertFilterModel filterModel)
        {
            TempData["StatusMessage"] = null;
            TempData["StatusCode"]    = JobAlertStatus.SUCCESS;
            dynamic dynamicFilterResponse                = new ExpandoObject();
            JXTNext_GetJobFiltersRequest request         = new JXTNext_GetJobFiltersRequest();
            IGetJobFiltersResponse       filtersResponse = _OConnector.JobFilters <JXTNext_GetJobFiltersRequest, JXTNext_GetJobFiltersResponse>(request);
            //if (filtersResponse != null && filtersResponse.Filters != null
            //    && filtersResponse.Filters.Data != null)
            //    dynamicFilterResponse = filtersResponse.Filters.Data as dynamic;


            List <JobFilterRoot> fitersData = null;

            if (filtersResponse != null && filtersResponse.Filters != null &&
                filtersResponse.Filters.Data != null)
            {
                fitersData = filtersResponse.Filters.Data;
            }

            var serializeFilterData = JsonConvert.SerializeObject(fitersData);
            var filtersVMList       = JsonConvert.DeserializeObject <List <JobAlertEditFilterRootItem> >(serializeFilterData);

            if (filterModel.Filters != null && filterModel.Filters.Count > 0)
            {
                foreach (var rootItem in filterModel.Filters)
                {
                    if (rootItem != null)
                    {
                        if (filtersVMList != null && filtersVMList.Count > 0)
                        {
                            foreach (var filterVMRootItem in filtersVMList)
                            {
                                if (filterVMRootItem.Name == rootItem.RootId)
                                {
                                    if (filterVMRootItem.Filters != null && filterVMRootItem.Filters.Count > 0)
                                    {
                                        foreach (var filterItem in filterVMRootItem.Filters)
                                        {
                                            // Here we are coming the ids as parent child relationship and we need
                                            // Only the current id, so remove underscore and get the exact id
                                            RemoveUnderScore(rootItem.Values);
                                            MergeFilters(filterItem, rootItem.Values);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            dynamicFilterResponse.Filters  = filtersVMList as dynamic;
            ViewBag.IsMemberUser           = SitefinityHelper.IsUserLoggedIn("Member");
            dynamicFilterResponse.Keywords = filterModel.Keywords;
            dynamicFilterResponse.Salary   = filterModel.Salary;


            return(View("Create", dynamicFilterResponse));
        }
        private string GetClassificationNameById(string classificationId)
        {
            var topLovelCategories = SitefinityHelper.GetTopLevelCategories();

            foreach (var taxon in topLovelCategories)
            {
                JobFilterRoot filterRoot = new JobFilterRoot()
                {
                    Filters = new List <JobFilter>()
                };
                filterRoot.ID   = taxon.Id.ToString().ToUpper();
                filterRoot.Name = taxon.Title;
                if (classificationId == filterRoot.ID)
                {
                    return(filterRoot.Name);
                }
                var hierarchicalTaxon = taxon as HierarchicalTaxon;
                if (hierarchicalTaxon != null)
                {
                    foreach (var childTaxon in hierarchicalTaxon.Subtaxa)
                    {
                        var jobFilter = new JobFilter()
                        {
                            Filters = new List <JobFilter>()
                        };
                        ProcessCategories(childTaxon, jobFilter);
                        filterRoot.Filters.Add(jobFilter);
                    }
                }
            }
            return(null);
        }
Exemple #6
0
        public JobDetailsRolesModel()
        {
            if (string.IsNullOrWhiteSpace(this.SerializedJobDetailsRoles))
            {
                var roleOptions = new List <JobDetailsRolesOptions>();
                var roleNames   = SitefinityHelper.GetAllRoleNames();

                foreach (var roleName in roleNames)
                {
                    roleOptions.Add(new JobDetailsRolesOptions()
                    {
                        RoleName = roleName, IsChecked = false
                    });
                }

                if (!roleNames.Contains("Anonymous"))
                {
                    roleOptions.Add(new JobDetailsRolesOptions()
                    {
                        RoleName = "Anonymous", IsChecked = false
                    });
                }

                this.SerializedJobDetailsRoles = JsonConvert.SerializeObject(roleOptions);
            }
        }
Exemple #7
0
        public bool IsJobApplyAvailable()
        {
            List <string> roles         = SitefinityHelper.GetCurrentUserRoles();
            var           roleOptions   = JsonConvert.DeserializeObject <List <JobDetailsRolesOptions> >(this.SerializedJobDetailsRoles);
            List <string> selectedRoles = new List <string>();

            foreach (var roleOpt in roleOptions)
            {
                if (roleOpt.IsChecked == true)
                {
                    selectedRoles.Add(roleOpt.RoleName);
                }
            }
            if (roles.Intersect(selectedRoles).Any())
            {
                return(true);
            }

            foreach (var roleOpt in roleOptions)
            {
                if (roleOpt.RoleName == "Anonymous" && roleOpt.IsChecked == true)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #8
0
        public JXTNextResumeController(IJobApplicationService jobApplicationService, IBusinessLogicsConnector blConnector)
        {
            _jobApplicationService = jobApplicationService;
            _blConnector           = blConnector;
            resumeList             = new List <ProfileResumeJsonModel>();


            Email = SitefinityHelper.GetLoggedInUserEmail();
        }
        private string GetJobAlertHtmlEmailTitle()
        {
            string htmlEmailTitle = String.Empty;

            if (!String.IsNullOrEmpty(this.JobAlertEmailTemplateId))
            {
                htmlEmailTitle = SitefinityHelper.GetCurrentSiteEmailTemplateTitle(this.JobAlertEmailTemplateId);
            }
            return(htmlEmailTitle);
        }
Exemple #10
0
        // GET: JobAlert
        public ActionResult Index()
        {
            List <JobAlertViewModel> jobAlertData = _jobAlertService.MemberJobAlertsGet();

            ViewBag.CssClass      = this.CssClass;
            ViewBag.Status        = TempData["StatusCode"];
            ViewBag.StatusMessage = TempData["StatusMessage"];
            ViewBag.IsMemberUser  = SitefinityHelper.IsUserLoggedIn("Member");

            return(View("Simple", jobAlertData));
        }
        private ISearchJobsResponse GetJobSearchResultsResponse(JobSearchResultsFilterModel filterModel)
        {
            if (!this.PageSize.HasValue || this.PageSize.Value <= 0)
            {
                this.PageSize = PageSizeDefaultValue;
            }

            JXTNext_SearchJobsRequest request = JobSearchResultsFilterModel.ProcessInputToSearchRequest(filterModel, this.PageSize, PageSizeDefaultValue);

            string sortingBy = this.Sorting;

            if (filterModel != null && !filterModel.SortBy.IsNullOrEmpty())
            {
                sortingBy = filterModel.SortBy;
            }

            request.SortBy    = JobSearchResultsFilterModel.GetSortEnumFromString(sortingBy);
            ViewBag.SortOrder = JobSearchResultsFilterModel.GetSortStringFromEnum(request.SortBy);

            ISearchJobsResponse        response       = _BLConnector.SearchJobs(request);
            JXTNext_SearchJobsResponse jobResultsList = response as JXTNext_SearchJobsResponse;


            ViewBag.Request     = JsonConvert.SerializeObject(filterModel);
            ViewBag.FilterModel = JsonConvert.SerializeObject(filterModel);
            ViewBag.PageSize    = (int)this.PageSize;
            ViewBag.CssClass    = this.CssClass;
            if (jobResultsList != null)
            {
                ViewBag.TotalCount = jobResultsList.Total;
            }

            ViewBag.JobResultsPageUrl = SfPageHelper.GetPageUrlById(ResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(ResultsPageId));
            ViewBag.CurrentPageUrl    = SfPageHelper.GetPageUrlById(SiteMapBase.GetActualCurrentNode().Id);
            ViewBag.JobDetailsPageUrl = SfPageHelper.GetPageUrlById(DetailsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(DetailsPageId));
            ViewBag.EmailJobPageUrl   = SfPageHelper.GetPageUrlById(EmailJobPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(EmailJobPageId));
            ViewBag.HidePushStateUrl  = this.HidePushStateUrl;
            ViewBag.PageFullUrl       = SfPageHelper.GetPageUrlById(SiteMapBase.GetActualCurrentNode().Id);
            ViewBag.IsMember          = SitefinityHelper.IsUserLoggedIn("Member");

            var currentIdentity = ClaimsManager.GetCurrentIdentity();

            if (currentIdentity.IsAuthenticated)
            {
                var currUser = SitefinityHelper.GetUserById(currentIdentity.UserId);
                if (currUser != null)
                {
                    ViewBag.Email = currUser.Email;
                }
            }

            return(response);
        }
Exemple #12
0
        private IMemberUpsertJobAlertResponse GetUpsertResponse(JobAlertViewModel model, bool update = false)
        {
            JobAlertSalaryFilterReceiver salary = null;

            if (!model.SalaryStringify.IsNullOrEmpty())
            {
                salary = JsonConvert.DeserializeObject <JobAlertSalaryFilterReceiver>(model.SalaryStringify);
            }

            if (salary != null)
            {
                model.Salary = salary;
            }

            var epochTime = ConversionHelper.GetUnixTimestamp(SitefinityHelper.GetSitefinityApplicationTime(), true);

            model.LastModifiedTime = (long)epochTime;

            // Remove null value filters
            List <JobAlertFilters> Filters = new List <JobAlertFilters>();

            if (model != null && model.Filters != null && model.Filters.Count > 0)
            {
                foreach (var item in model.Filters)
                {
                    if (item.Values != null && item.Values.Count > 0)
                    {
                        Filters.Add(item);
                    }
                }
            }

            model.Filters = Filters;

            if (model != null && model.Email.IsNullOrEmpty())
            {
                model.Email = SitefinityHelper.GetLoggedInUserEmail();
            }

            var response = _jobAlertService.MemberJobAlertUpsert(model, update);

            return(response);
        }
        /// <summary>
        /// Handle sign-in with LinkedIn.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private LinkedInSignInViewModel HandleLinkedInSignIn(LinkedInSignInRequest request)
        {
            var viewModel = new LinkedInSignInViewModel();

            if (SitefinityHelper.IsUserLoggedIn())
            {
                return(viewModel);
            }

            if (!LinkedInHelper.IsValidState(request.State))
            {
                viewModel.Error = "The response from LinkedIn is in invalid state. Please go back and try again.";

                return(viewModel);
            }

            var redirectUrl = LinkedInHelper.CreateSignInRedirectUrl(request.Redirect, request.Data);

            try
            {
                var accessTokenResponse = LinkedInHelper.GetAccessTokenFromAuthorisationCode(request.Code, redirectUrl);

                if (string.IsNullOrEmpty(accessTokenResponse.Error))
                {
                    if (!CreateUserFromLinkedInProfileData(accessTokenResponse.AccessToken))
                    {
                        viewModel.Error = "There was some problem while sign-in. Please go back and try again.";
                    }
                }
                else
                {
                    viewModel.Error = accessTokenResponse.Error;
                }
            }
            catch (Exception err)
            {
                viewModel.Error = "There was some problem during authentication with LinkedIn. Please go back and try again.";

                Log.Write(err);
            }

            return(viewModel);
        }
Exemple #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SitefinityProfileItemViewModel" /> class.
        /// </summary>
        /// <param name="dataItem">The data item.</param>
        public SitefinityProfileItemExtendedViewModel(IDataItem dataItem)
            : base(dataItem)
        {
            var sfProfile          = dataItem as UserProfile;
            var displayNameBuilder = new SitefinityUserDisplayNameBuilder();

            Telerik.Sitefinity.Libraries.Model.Image avatarImage;
            this.AvatarImageUrl = displayNameBuilder.GetAvatarImageUrl(sfProfile.User.Id, out avatarImage);
            this.FirstName      = SitefinityHelper.GetUserFirstNameById(sfProfile.User.Id);

            dynamic profile = sfProfile as dynamic;

            PropertyInfo[] pInfos            = sfProfile.GetType().GetProperties();
            PropertyInfo   aboutPropertyInfo = pInfos.Where(c => c.Name.ToUpper() == "ABOUT").FirstOrDefault();

            if (aboutPropertyInfo != null)
            {
                this.About = aboutPropertyInfo.GetValue(sfProfile) as String;
            }
        }
 public JobFiltersDesignerViewModel()
 {
     if (string.IsNullOrWhiteSpace(this.SerializedJobFilterModel))
     {
         var filterModel        = new List <JobFiltersModel>();
         var topLovelCategories = SitefinityHelper.GetTopLevelCategories();
         int index = 1;
         foreach (var taxon in topLovelCategories)
         {
             filterModel.Add(new JobFiltersModel()
             {
                 TaxonamyName = taxon.Title, TaxonomyId = taxon.Id.ToString(), Selected = false, TrackId = index
             });
             index++;
         }
         filterModel.Add(new JobFiltersModel()
         {
             TaxonamyName = "CompanyName", Selected = false, TrackId = index
         });
         this.SerializedJobFilterModel = JsonConvert.SerializeObject(filterModel);
     }
 }
        public static JobFiltersData GetFiltersData()
        {
            JobFiltersData filtersData = new JobFiltersData()
            {
                Data = new List <JobFilterRoot>()
            };
            var topLovelCategories = SitefinityHelper.GetTopLevelCategories();

            foreach (var taxon in topLovelCategories)
            {
                JobFilterRoot filterRoot = new JobFilterRoot()
                {
                    Filters = new List <JobFilter>()
                };
                filterRoot.ID   = taxon.Id.ToString().ToUpper();
                filterRoot.Name = taxon.Title;

                var hierarchicalTaxon = taxon as HierarchicalTaxon;
                if (hierarchicalTaxon != null)
                {
                    foreach (var childTaxon in hierarchicalTaxon.Subtaxa)
                    {
                        var jobFilter = new JobFilter()
                        {
                            Filters = new List <JobFilter>()
                        };
                        ProcessCategories(childTaxon, jobFilter);
                        filterRoot.Filters.Add(jobFilter);
                    }
                }

                filtersData.Data.Add(filterRoot);
            }

            return(filtersData);
        }
        public IMemberUpsertJobAlertResponse MemberJobAlertUpsert(JobAlertViewModel jobAlertData, bool update = false)
        {
            int?memberJobAlertId = null;

            if (update)
            {
                memberJobAlertId = jobAlertData.Id;
            }

            IMemberUpsertJobAlertRequest request = new JXTNext_MemberUpsertJobAlertRequest
            {
                Name              = jobAlertData.Name,
                DateCreated       = jobAlertData.LastModifiedTime,
                Data              = jobAlertData.Data,
                Status            = 1,
                MemberJobAlertId  = memberJobAlertId,
                Email             = jobAlertData.Email,
                EmailNotification = jobAlertData.EmailNotifications
            };
            IMemberUpsertJobAlertResponse response = _BLconnector.MemberUpsertJobAlert(request, SitefinityHelper.IsUserLoggedIn());

            return(response);
        }
Exemple #18
0
        // GET: JobDetails
        public ActionResult Index(int?jobId)
        {
            JobDetailsViewModel viewModel = new JobDetailsViewModel();

            if (jobId.HasValue)
            {
                // Get job source or url referral

                string UrlReferral = string.Empty;
                if (!string.IsNullOrWhiteSpace(Request.QueryString["source"]))
                {
                    UrlReferral = Request.QueryString["source"];
                }
                else
                {
                    UrlReferral = this.GetCookieDomain(Request.Cookies["JobsViewed"], jobId.Value);
                }

                viewModel.UrlReferral = UrlReferral;
                Log.Write($" viewModel.UrlReferral  : " + viewModel.UrlReferral, ConfigurationPolicy.ErrorLog);

                IGetJobListingRequest jobListingRequest = new JXTNext_GetJobListingRequest {
                    JobID = jobId.Value
                };
                IGetJobListingResponse jobListingResponse = _BLConnector.GuestGetJob(jobListingRequest);

                if (jobListingResponse.Job != null && !jobListingResponse.Job.IsDeleted)
                {
                    viewModel.JobDetails = jobListingResponse.Job;

                    // Getting Consultant Avatar Image Url from Sitefinity
                    viewModel.ApplicationEmail = jobListingResponse.Job.CustomData["ApplicationMethod.ApplicationEmail"];
                    var user = SitefinityHelper.GetUserByEmail(jobListingResponse.Job.CustomData["ApplicationMethod.ApplicationEmail"]);
                    if (user != null && user.Id != Guid.Empty)
                    {
                        viewModel.ApplicationAvatarImageUrl = SitefinityHelper.GetUserAvatarUrlById(user.Id);
                    }

                    if (this.Model.IsJobApplyAvailable())
                    {
                        viewModel.JobApplyAvailable = true;
                    }

                    // Processing Classifications
                    OrderedDictionary classifOrdDict = new OrderedDictionary();
                    classifOrdDict.Add(jobListingResponse.Job.CustomData["Classifications[0].Filters[0].ExternalReference"], jobListingResponse.Job.CustomData["Classifications[0].Filters[0].Value"]);
                    string parentClassificationsKey = "Classifications[0].Filters[0].SubLevel[0]";
                    JobDetailsViewModel.ProcessCustomData(parentClassificationsKey, jobListingResponse.Job.CustomData, classifOrdDict);
                    OrderedDictionary classifParentIdsOrdDict = new OrderedDictionary();
                    JobDetailsViewModel.AppendParentIds(classifOrdDict, classifParentIdsOrdDict);

                    var bull = jobListingResponse.Job.CustomData["Bulletpoints.BulletPoint1"];

                    // Processing Locations
                    OrderedDictionary locOrdDict = new OrderedDictionary();
                    locOrdDict.Add(jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].ExternalReference"], jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].Value"]);
                    string parentLocKey = "CountryLocationArea[0].Filters[0].SubLevel[0]";
                    JobDetailsViewModel.ProcessCustomData(parentLocKey, jobListingResponse.Job.CustomData, locOrdDict);
                    OrderedDictionary locParentIdsOrdDict = new OrderedDictionary();
                    JobDetailsViewModel.AppendParentIds(locOrdDict, locParentIdsOrdDict);

                    DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.DateCreated), TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time"));
                    DateTime utcTime   = ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.DateCreated);
                    DateTime elocalTime;
                    DateTime eutcTime = new DateTime();
                    TimeSpan offset   = localTime - utcTime;
                    TimeSpan eoffset  = new TimeSpan();


                    if (jobListingResponse.Job.ExpiryDate.HasValue)
                    {
                        elocalTime = TimeZoneInfo.ConvertTimeFromUtc(ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.ExpiryDate.Value), TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time"));
                        eutcTime   = ConversionHelper.GetDateTimeFromUnix(jobListingResponse.Job.ExpiryDate.Value);
                        eoffset    = elocalTime - eutcTime;
                    }

                    viewModel.Classifications         = classifParentIdsOrdDict;
                    viewModel.Locations               = locParentIdsOrdDict;
                    viewModel.ClassificationsRootName = "Classifications";
                    viewModel.LocationsRootName       = "CountryLocationArea";
                    var siteSettingsHelper = new SiteSettingsHelper();
                    viewModel.JobCurrencySymbol = siteSettingsHelper.GetJobCurrencySymbol();

                    // Getting the SEO route name for classifications
                    List <string> seoString = new List <string>();
                    foreach (var key in classifParentIdsOrdDict.Keys)
                    {
                        string value     = classifParentIdsOrdDict[key].ToString();
                        string SEOString = Regex.Replace(value, @"([^\w]+)", "-");
                        seoString.Add(SEOString);
                    }

                    viewModel.ClassificationsSEORouteName = jobListingResponse.Job.ClassificationURL;

                    ViewBag.CssClass = this.CssClass;
                    ViewBag.JobApplicationPageUrl = SfPageHelper.GetPageUrlById(JobApplicationPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(JobApplicationPageId));
                    ViewBag.JobResultsPageUrl     = SfPageHelper.GetPageUrlById(JobResultsPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(JobResultsPageId));
                    ViewBag.EmailJobPageUrl       = SfPageHelper.GetPageUrlById(EmailJobPageId.IsNullOrWhitespace() ? Guid.Empty : new Guid(EmailJobPageId));
                    ViewBag.GoogleForJobs         = ReplaceToken(GoogleForJobsTemplate, JsonConvert.SerializeObject(new
                    {
                        CurrencySymbol        = "$",
                        SalaryLowerBand       = jobListingResponse.Job.CustomData.ContainsKey("Salaries[0].Filters[0].Min") ? jobListingResponse.Job.CustomData["Salaries[0].Filters[0].Min"] : null,
                        SalaryUpperBand       = jobListingResponse.Job.CustomData.ContainsKey("Salaries[0].Filters[0].Max") ? jobListingResponse.Job.CustomData["Salaries[0].Filters[0].Max"] : null,
                        FullDescription       = jobListingResponse.Job.Description,
                        Description           = jobListingResponse.Job.ShortDescription,
                        AdvertiserCompanyName = jobListingResponse.Job.CustomData.ContainsKey("CompanyName") ? jobListingResponse.Job.CustomData["CompanyName"] : null,
                        ProfessionName        = jobListingResponse.Job.CustomData.ContainsKey("Classifications[0].Filters[0].Value") ? jobListingResponse.Job.CustomData["Classifications[0].Filters[0].Value"] : null,
                        LocationName          = jobListingResponse.Job.CustomData.ContainsKey("CountryLocationArea[0].Filters[0].Value") ? jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].Value"] : null,
                        AreaName   = jobListingResponse.Job.CustomData.ContainsKey("CountryLocationArea[0].Filters[0].SubLevel[0].Value") ? jobListingResponse.Job.CustomData["CountryLocationArea[0].Filters[0].SubLevel[0].Value"] : null,
                        JobName    = jobListingResponse.Job.Title,
                        DatePosted = string.Format("|{0}+{1}|", utcTime.ToString("yyyy-MM-ddThh:mm:ss"), offset.Hours.ToString("00") + ":" + offset.Minutes.ToString("00")),
                        ExpiryDate = (jobListingResponse.Job.ExpiryDate.HasValue) ? string.Format("|{0}+{1}|", eutcTime.ToString("yyyy-MM-ddThh:mm:ss"), eoffset.Hours.ToString("00") + ":" + eoffset.Minutes.ToString("00")) : string.Empty,
                        Address    = jobListingResponse.Job.Address
                    }));
                    var fullTemplateName = this.templateNamePrefix + this.TemplateName;
                    // If it is null make sure that pass empty string , because html attrubutes will not work properly.
                    viewModel.JobDetails.Address           = viewModel.JobDetails.Address == null ? "" : viewModel.JobDetails.Address;
                    viewModel.JobDetails.AddressLatitude   = viewModel.JobDetails.AddressLatitude == null ? "" : viewModel.JobDetails.AddressLatitude;
                    viewModel.JobDetails.AddressLongtitude = viewModel.JobDetails.AddressLongtitude == null ? "" : viewModel.JobDetails.AddressLongtitude;

                    #region Check job already applied
                    ViewBag.IsJobApplied = false;
                    JXTNext_MemberAppliedJobResponse response = _BLConnector.MemberAppliedJobsGet() as JXTNext_MemberAppliedJobResponse;
                    if (response.Success)
                    {
                        foreach (var item in response.MemberAppliedJobs)
                        {
                            if (item.JobId == jobId.Value)
                            {
                                ViewBag.IsJobApplied = true;
                                break;
                            }
                        }
                    }
                    #endregion
                    var meta = new System.Web.UI.HtmlControls.HtmlMeta();
                    meta.Attributes.Add("property", "og:title");
                    meta.Content = jobListingResponse.Job.Title;

                    // Get the current page handler in order to access the page header
                    var pageHandler = this.HttpContext.CurrentHandler.GetPageHandler();
                    pageHandler.Header.Controls.Add(meta);
                    return(View(fullTemplateName, viewModel));
                }
                else
                {
                    if (jobListingResponse.Job != null && jobListingResponse.Job.IsDeleted)
                    {
                        return(Content("This Job is no longer available!"));
                    }
                    else
                    {
                        return(Content("No job has been found"));
                    }
                }
            }

            return(Content("No job has been selected"));
        }
Exemple #19
0
        public string GetOverrideEmail(ref JobApplicationStatus status, ref ApplicantInfo applicantInfo, bool isSocialMedia = false)
        {
            string ovverideEmail = null;

            if (SitefinityHelper.IsUserLoggedIn()) // User already logged in
            {
                var currUser = SitefinityHelper.GetUserById(ClaimsManager.GetCurrentIdentity().UserId);
                if (currUser != null)
                {
                    Log.Write("User is already logged In " + currUser.Email, ConfigurationPolicy.ErrorLog);
                    return(currUser.Email);
                }
            }

            // User not looged in
            if (!string.IsNullOrEmpty(applicantInfo.Email))
            {
                Telerik.Sitefinity.Security.Model.User existingUser = SitefinityHelper.GetUserByEmail(applicantInfo.Email);

                if (existingUser != null)
                {
                    #region Entered Email exists in Sitefinity User list
                    Log.Write("User is already exists in portal " + existingUser.Email, ConfigurationPolicy.ErrorLog);
                    ovverideEmail = existingUser.Email;
                    // check user exists in the JXT next DB
                    var memberResponse = _blConnector.GetMemberByEmail(applicantInfo.Email);
                    if (memberResponse.Member == null)
                    {
                        UserProfileManager userProfileManager = UserProfileManager.GetManager();
                        UserProfile        profile            = userProfileManager.GetUserProfile(existingUser.Id, typeof(SitefinityProfile).FullName);
                        var fName = Telerik.Sitefinity.Model.DataExtensions.GetValue(profile, "FirstName");
                        var lName = Telerik.Sitefinity.Model.DataExtensions.GetValue(profile, "LastName");
                        JXTNext_MemberRegister memberReg = new JXTNext_MemberRegister
                        {
                            Email     = existingUser.Email,
                            FirstName = fName.ToString(),
                            LastName  = lName.ToString(),
                            Password  = existingUser.Password
                        };

                        if (_blConnector.MemberRegister(memberReg, out string errorMessage))
                        {
                            Log.Write("User created JXT next DB" + existingUser.Email, ConfigurationPolicy.ErrorLog);
                        }
                    }
                    return(ovverideEmail);

                    #endregion
                }
                else
                {
                    #region Entered email does not exists in sitefinity User list
                    var membershipCreateStatus = SitefinityHelper.CreateUser(applicantInfo.Email, applicantInfo.Password, applicantInfo.FirstName, applicantInfo.LastName, applicantInfo.Email, applicantInfo.PhoneNumber,
                                                                             null, null, true, true);
                    applicantInfo.IsNewUser = true;
                    if (membershipCreateStatus != MembershipCreateStatus.Success)
                    {
                        Log.Write("User is created in portal " + existingUser.Email, ConfigurationPolicy.ErrorLog);
                        status = JobApplicationStatus.NotAbleToCreateUser;
                        return(ovverideEmail);
                    }
                    else
                    {
                        //instantiate the Sitefinity user manager
                        //if you have multiple providers you have to pass the provider name as parameter in GetManager("ProviderName") in your case it will be the asp.net membership provider user
                        UserManager userManager = UserManager.GetManager();
                        if (userManager.ValidateUser(applicantInfo.Email, applicantInfo.Password))
                        {
                            //if you need to get the user instance use the out parameter
                            Telerik.Sitefinity.Security.Model.User userToAuthenticate = null;
                            SecurityManager.AuthenticateUser(userManager.Provider.Name, applicantInfo.Email, applicantInfo.Password, false, out userToAuthenticate);
                            if (userToAuthenticate == null)
                            {
                                status = JobApplicationStatus.NotAbleToLoginCreatedUser;
                                return(ovverideEmail);
                            }
                            else
                            {
                                ovverideEmail = userToAuthenticate.Email;
                            }
                        }
                    }
                    #endregion
                }
            }

            return(ovverideEmail);
        }
        private bool _SendEmail(JobEmailFormModel form, JobDetailsFullModel job)
        {
            var subject = string.IsNullOrWhiteSpace(this.EmailSubject) ? "Job for you" : this.EmailSubject;

            var content = _GetHtmlEmailContent();

            var emailSender = new SitefinityEmailSender();

            // ideally there should be a common method to get a job's url
            // doing this due to lack of such method
            var jobUrl = Request.Url.Scheme + "://" + Request.Url.Authority;

            if (!string.IsNullOrWhiteSpace(JobDetailsPageId))
            {
                jobUrl += SitefinityHelper.GetPageUrl(JobDetailsPageId);

                if (job.ClassificationURL != null)
                {
                    jobUrl += "/" + job.ClassificationURL;
                }

                jobUrl += "/" + job.JobID;
            }


            dynamic templateData = new ExpandoObject();

            templateData.Job       = new ExpandoObject();
            templateData.Job.Id    = job.JobID;
            templateData.Job.Title = job.Title;
            templateData.Job.Url   = jobUrl;
            templateData.Domain    = HttpContext.GetCurrentDomain();

            var result = false;

            // if the email is not set then create one using current site's domain name
            var fromEmail = this.EmailFromEmail;

            if (string.IsNullOrEmpty(fromEmail))
            {
                fromEmail = "noreply@" + Request.Url.Host;
            }

            if (form.EmailFriend)
            {
                var from = new MailAddress(fromEmail, form.Name);

                var replyToCollection = new MailAddressCollection();
                replyToCollection.Add(new MailAddress(form.Email, form.Name));

                templateData.Sender = from;

                if (form.FriendMessage == null)
                {
                    templateData.Message = string.Empty;
                }
                else
                {
                    templateData.Message = Regex.Replace(form.FriendMessage, "<.*?>", String.Empty).Replace("\n", "<br />");
                }

                foreach (var item in form.Friend)
                {
                    var emailRequest = new EmailRequest
                    {
                        To        = new MailAddress(item.Email, item.Name),
                        ReplyTo   = replyToCollection,
                        From      = from,
                        Subject   = subject,
                        EmailBody = content
                    };

                    templateData.Recipient = emailRequest.To;

                    if (emailSender.SendEmail(emailRequest, templateData))
                    {
                        result = true;
                    }
                }
            }
            else
            {
                // if the name is not set then use current site's name
                var fromName = this.EmailFromName;
                if (string.IsNullOrEmpty(fromName))
                {
                    fromName = new MultisiteContext().CurrentSite.Name;
                }

                var emailRequest = new EmailRequest
                {
                    To        = new MailAddress(form.Email, form.Name),
                    From      = new MailAddress(fromEmail, fromName),
                    Subject   = subject,
                    EmailBody = content
                };

                templateData.Recipient = emailRequest.To;
                templateData.Sender    = emailRequest.From;
                templateData.Message   = string.Empty;

                result = emailSender.SendEmail(emailRequest, templateData);
            }

            return(result);
        }
        public ActionResult LinkedInApply(int jobId, string profileJson)
        {
            var response = new LinkedInApplyResponse();

            // user must be logged in to apply for a job
            if (!SitefinityHelper.IsUserLoggedIn())
            {
                response.Errors.Add("You must be logged in to apply for a job.");

                return(Json(response));
            }

            // check whether requested job exist or not
            var jobDetails = GetJobDetails(jobId);

            if (jobDetails == null)
            {
                response.Errors.Add("Job does not exist.");

                return(Json(response));
            }

            // process the submitted LinkedIn data
            var processLinkedInData = new ProcessLinkedInData();
            var result = processLinkedInData.ProcessData(null, null, profileJson);

            if (result == null || !result.Success)
            {
                response.Errors = result.Errors;

                return(Json(response));
            }

            result.JobId = jobId;
            if (TempData["Urlreferal"] != null)
            {
                result.UrlReferral = TempData["Urlreferal"].ToString();
            }


            var viewModel = new SocialMediaJobViewModel
            {
                Status = JobApplicationStatus.Available
            };

            ApplicantInfo applicantInfo = new ApplicantInfo()
            {
                FirstName   = result.FirstName,
                LastName    = result.LastName,
                Email       = result.Email,
                PhoneNumber = result.PhoneNumber,
                IsNewUser   = false
            };

            // create the job application and redirect to success page if possible
            var applicationResponse = CreateJobApplication(result, jobDetails, applicantInfo, result.Email);

            if (applicationResponse.Status == JobApplicationStatus.Applied_Successful)
            {
                response.Success = true;
                response.Messages.Add(applicationResponse.Message);

                if (!string.IsNullOrEmpty(this.JobApplicationSuccessPageId))
                {
                    response.RedirectUrl = SitefinityHelper.GetPageUrl(this.JobApplicationSuccessPageId);
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(applicationResponse.Message))
                {
                    response.Errors.Add("An unexpected error occurred while processing your request. Please try again.");
                }
                else
                {
                    response.Errors.Add(applicationResponse.Message);
                }
            }

            return(Json(response));
        }
Exemple #22
0
        public ActionResult Create(JobAlertViewModel model)
        {
            List <JobAlertEditFilterRootItem> filtersVMList = GetJobFilterData();

            if (model.SalaryStringify != null)
            {
                model.Salary = JsonConvert.DeserializeObject <JobAlertSalaryFilterReceiver>(model.SalaryStringify);
            }

            if (String.IsNullOrEmpty(model.Email))
            {
                model.Email = SitefinityHelper.GetLoggedInUserEmail();
            }

            model.Data = JobAlertUtility.ConvertJobAlertViewModelToSearchModel(model, filtersVMList);
            // Create Email Notification
            EmailNotificationSettings jobAlertEmailNotificationSettings = null;

            if (this.JobAlertEmailTemplateId != null)
            {
                jobAlertEmailNotificationSettings = new EmailNotificationSettings(new EmailTarget(this.JobAlertEmailTemplateSenderName, this.JobAlertEmailTemplateSenderEmailAddress),
                                                                                  new EmailTarget(string.Empty, model.Email),
                                                                                  SitefinityHelper.GetCurrentSiteEmailTemplateTitle(this.JobAlertEmailTemplateId),
                                                                                  SitefinityHelper.GetCurrentSiteEmailTemplateHtmlContent(this.JobAlertEmailTemplateId), null);
                if (!this.JobAlertEmailTemplateCC.IsNullOrEmpty())
                {
                    foreach (var ccEmail in this.JobAlertEmailTemplateCC.Split(';'))
                    {
                        jobAlertEmailNotificationSettings?.AddCC(String.Empty, ccEmail);
                    }
                }

                if (!this.JobAlertEmailTemplateBCC.IsNullOrEmpty())
                {
                    foreach (var bccEmail in this.JobAlertEmailTemplateBCC.Split(';'))
                    {
                        jobAlertEmailNotificationSettings?.AddBCC(String.Empty, bccEmail);
                    }
                }
            }


            model.EmailNotifications = jobAlertEmailNotificationSettings;
            var response     = GetUpsertResponse(model);
            var stausMessage = "A Job Alert has been created successfully.";
            var alertStatus  = JobAlertStatus.SUCCESS;

            if (!response.Success)
            {
                stausMessage = response.Errors.First();
                alertStatus  = JobAlertStatus.CREATE_FAILED;
            }

            TempData["StatusCode"]    = alertStatus;
            TempData["StatusMessage"] = stausMessage;

            // Why action name is empty?
            // Here we need to call Index action, if we are providing action name as Index here
            // It is appending in the URL, but we dont want to show that in URL. So, sending it as empty
            // Will definity call defaut action i,.e Index
            return(RedirectToAction(""));
        }
        private CreateJobApplicationResponse CreateJobApplication(
            SocialMediaProcessedResponse result,
            JobDetailsModel jobDetails,
            ApplicantInfo applicantInfo,
            string overrideEmail)
        {
            // Gather Attachments
            Guid identifier = Guid.NewGuid();
            JobApplicationAttachmentUploadItem uploadItem = new JobApplicationAttachmentUploadItem()
            {
                Id               = identifier.ToString(),
                AttachmentType   = JobApplicationAttachmentType.Resume,
                FileName         = result.FileName,
                FileStream       = result.FileStream,
                PathToAttachment = identifier.ToString() + "_" + result.FileName,
                Status           = "Ready"
            };



            // End code for fetch job details
            Log.Write("overrideEmail uploadItem object created", ConfigurationPolicy.ErrorLog);
            List <JobApplicationAttachmentUploadItem> attachments = new List <JobApplicationAttachmentUploadItem>();

            attachments.Add(uploadItem);
            Log.Write("overrideEmail uploadItem attachment added", ConfigurationPolicy.ErrorLog);
            string resumeAttachmentPath = JobApplicationAttachmentUploadItem.GetAttachmentPath(attachments, JobApplicationAttachmentType.Resume);

            Log.Write("After resume GetAttachmentPath", ConfigurationPolicy.ErrorLog);
            string coverletterAttachmentPath = JobApplicationAttachmentUploadItem.GetAttachmentPath(attachments, JobApplicationAttachmentType.Coverletter);

            Log.Write("After cover letter GetAttachmentPath", ConfigurationPolicy.ErrorLog);

            string htmlEmailContent           = this.GetEmailHtmlContent(this.EmailTemplateId);
            string htmlEmailSubject           = this.GetEmailSubject(this.EmailTemplateId);
            string htmlAdvertiserEmailContent = this.GetEmailHtmlContent(this.AdvertiserEmailTemplateId);
            string htmlAdvertiserEmailSubject = this.GetEmailSubject(this.AdvertiserEmailTemplateId);

            Log.Write("After GetHtmlEmailContent", ConfigurationPolicy.ErrorLog);
            // Email notification settings


            List <dynamic> emailAttachments = new List <dynamic>();

            foreach (var item in attachments)
            {
                dynamic emailAttachment = new ExpandoObject();
                emailAttachment.FileStream = item.FileStream;
                emailAttachment.FileName   = item.FileName;
                emailAttachments.Add(emailAttachment);
            }

            EmailNotificationSettings advertiserEmailNotificationSettings = (this.AdvertiserEmailTemplateId != null) ?
                                                                            _createAdvertiserEmailTemplate(
                new JobApplicationEmailTemplateModel()
            {
                FromFirstName = result.FirstName,
                FromLastName  = result.LastName,
                FromEmail     = overrideEmail,
                ToFirstName   = jobDetails.ContactDetails.GetFirstName(),
                ToLastName    = jobDetails.ContactDetails.GetLastName(),
                ToEmail       = jobDetails.ApplicationEmail,
                Subject       = SitefinityHelper.GetCurrentSiteEmailTemplateTitle(this.AdvertiserEmailTemplateId),
                HtmlContent   = SitefinityHelper.GetCurrentSiteEmailTemplateHtmlContent(this.AdvertiserEmailTemplateId),
                Attachments   = emailAttachments
            }) : null;



            EmailNotificationSettings emailNotificationSettings = (this.EmailTemplateId != null) ?
                                                                  _createApplicantEmailTemplate(
                new JobApplicationEmailTemplateModel()
            {
                FromFirstName = this.EmailTemplateSenderName,
                FromLastName  = null,
                FromEmail     = this.EmailTemplateSenderEmailAddress,
                ToFirstName   = SitefinityHelper.GetUserFirstNameById(SitefinityHelper.GetUserByEmail(overrideEmail).Id),
                ToLastName    = null,
                ToEmail       = overrideEmail,
                Subject       = SitefinityHelper.GetCurrentSiteEmailTemplateTitle(this.EmailTemplateId),
                HtmlContent   = SitefinityHelper.GetCurrentSiteEmailTemplateHtmlContent(this.EmailTemplateId),
                Attachments   = null
            }) : null;


            EmailNotificationSettings registrationNotificationsSettings = (applicantInfo.IsNewUser && this.RegistrationEmailTemplateId != null) ?
                                                                          _createRegistrationEmailTemplate(
                new JobApplicationEmailTemplateModel()
            {
                FromFirstName = this.EmailTemplateSenderName,
                FromLastName  = null,
                FromEmail     = this.EmailTemplateSenderEmailAddress,
                ToFirstName   = applicantInfo.FirstName,
                ToLastName    = null,
                ToEmail       = applicantInfo.Email,
                Subject       = SitefinityHelper.GetCurrentSiteEmailTemplateTitle(this.RegistrationEmailTemplateId),
                HtmlContent   = SitefinityHelper.GetCurrentSiteEmailTemplateHtmlContent(this.RegistrationEmailTemplateId),
                Attachments   = null
            }) : null;


            Log.Write("emailNotificationSettings after: ", ConfigurationPolicy.ErrorLog);

            Log.Write("BL response before: ", ConfigurationPolicy.ErrorLog);

            //Create Application
            var response = _blConnector.MemberCreateJobApplication(
                new JXTNext_MemberApplicationRequest
            {
                ApplyResourceID               = result.JobId.Value,
                MemberID                      = 2,
                ResumePath                    = resumeAttachmentPath,
                CoverletterPath               = coverletterAttachmentPath,
                EmailNotification             = emailNotificationSettings,
                AdvertiserEmailNotification   = advertiserEmailNotificationSettings,
                AdvertiserName                = jobDetails.ContactDetails,
                CompanyName                   = jobDetails.CompanyName,
                UrlReferral                   = result.UrlReferral,
                RegistrationEmailNotification = registrationNotificationsSettings
            },
                overrideEmail);

            Log.Write("BL response after: ", ConfigurationPolicy.ErrorLog);

            var createJobApplicationResponse = new CreateJobApplicationResponse {
                MemberApplicationResponse = response
            };

            if (response.Success && response.ApplicationID.HasValue)
            {
                Log.Write("BL response in: ", ConfigurationPolicy.ErrorLog);
                var hasFailedUpload = _jobApplicationService.UploadFiles(attachments);
                Log.Write("file upload is : " + hasFailedUpload, ConfigurationPolicy.ErrorLog);
                if (hasFailedUpload)
                {
                    createJobApplicationResponse.FilesUploaded = false;
                    createJobApplicationResponse.Status        = JobApplicationStatus.Technical_Issue; // Unable to attach files
                    createJobApplicationResponse.Message       = "Unable to attach files to application";
                }
                else
                {
                    createJobApplicationResponse.FilesUploaded = true;
                    createJobApplicationResponse.Status        = JobApplicationStatus.Applied_Successful;
                    createJobApplicationResponse.Message       = "Your application was successfully processed.";
                }
            }
            else
            {
                if (response.Errors.FirstOrDefault().ToLower().Contains("already exists"))
                {
                    createJobApplicationResponse.Status  = JobApplicationStatus.Already_Applied;
                    createJobApplicationResponse.Message = "You have already applied to this job.";
                }
                else
                {
                    createJobApplicationResponse.Status  = JobApplicationStatus.Technical_Issue;
                    createJobApplicationResponse.Message = response.Errors.FirstOrDefault();
                }
            }

            return(createJobApplicationResponse);
        }
 private string GetEmailSubject(string emailTemplateId)
 {
     //return _jobApplicationService.GetHtmlEmailContent("6AB317D4-D674-4636-8481-014BC6F861E1", this.EmailTemplateProviderName, this._itemType);
     return(SitefinityHelper.GetCurrentSiteEmailTemplateTitle(emailTemplateId));
 }
        public ActionResult Index(string code, string state, int?JobId)
        {
            SocialMediaJobViewModel viewModel = new SocialMediaJobViewModel();

            try
            {
                // Logging this info for Indeed test
                Log.Write("Social Handler Index Action Start : ", ConfigurationPolicy.ErrorLog);

                // This is the CSS classes enter from More Options
                ViewBag.CssClass = this.CssClass;

                if (string.IsNullOrWhiteSpace(this.TemplateName))
                {
                    this.TemplateName = "SocialHandler.Simple";
                }

                viewModel.Status = JobApplicationStatus.Available;

                if (_socialHandlerLogics != null)
                {
                    Log.Write("_socialHandlerLogics not null", ConfigurationPolicy.ErrorLog);
                    if (Request.InputStream != null)
                    {
                        Request.InputStream.Position = 0;
                    }

                    StreamReader reader = new StreamReader(Request.InputStream);
                    string       indeedJsonStringData  = String.Empty;
                    string       indeedJsonStringData2 = null;
                    if (reader != null)
                    {
                        indeedJsonStringData = reader.ReadToEnd();
                    }

                    using (StreamReader reader2 = new StreamReader(Request.InputStream, Encoding.UTF8))
                    {
                        indeedJsonStringData2 = reader.ReadToEnd();
                    }
                    SocialMediaProcessedResponse result = null;
                    if (!code.IsNullOrEmpty())
                    {
                        result = _processSocialMediaSeekData.ProcessData(code, state, indeedJsonStringData);
                        if (TempData["source"] != null && !string.IsNullOrWhiteSpace(TempData["source"].ToString()))
                        {
                            result.UrlReferral = TempData["source"].ToString();
                        }
                    }
                    else if (code.IsNullOrEmpty() && !indeedJsonStringData.IsNullOrEmpty())
                    {
                        result             = _processSocialMediaIndeedData.ProcessData(code, state, indeedJsonStringData);
                        result.UrlReferral = result.JobSource;
                    }
                    else
                    {
                        Log.Write("Social Handler code,sate and indeed data is null", ConfigurationPolicy.ErrorLog);
                    }


                    var jobDetails = GetJobDetails(result.JobId.Value);
                    //var result = _socialHandlerLogics.ProcessSocialHandlerData(code, state, indeedJsonStringData);
                    if (result != null && result.ResumeLinkNotExists)
                    {
                        if (!jobDetails.JobSEOUrl.IsNullOrEmpty())
                        {
                            return(Redirect(string.Format("job-application/{0}/{1}?error=resume", jobDetails.JobSEOUrl, int.Parse(state))));
                        }
                        else
                        {
                            return(Redirect(string.Format("job-application/{0}?error=resume", int.Parse(state))));
                        }
                    }


                    if (result != null && result.Success == true && result.JobId.HasValue)
                    {
                        JobApplicationStatus status = JobApplicationStatus.Available;
                        if (_jobApplicationService != null)
                        {
                            ApplicantInfo applicantInfo = new ApplicantInfo()
                            {
                                FirstName   = result.FirstName,
                                LastName    = result.LastName,
                                Email       = result.Email,
                                Password    = "******",
                                PhoneNumber = result.PhoneNumber,
                                IsNewUser   = false
                            };

                            string overrideEmail = string.Empty;
                            if (SitefinityHelper.IsUserLoggedIn())
                            {
                                var currUser = SitefinityHelper.GetUserById(ClaimsManager.GetCurrentIdentity().UserId);
                                if (currUser != null)
                                {
                                    Log.Write("User is already logged In " + currUser.Email, ConfigurationPolicy.ErrorLog);
                                    overrideEmail = currUser.Email;
                                }
                                else
                                {
                                    Log.Write("CurUser is null", ConfigurationPolicy.ErrorLog);
                                    overrideEmail = _jobApplicationService.GetOverrideEmail(ref status, ref applicantInfo, true);
                                }
                                Log.Write("SitefinityHelper.IsUserLoggedIn() =" + SitefinityHelper.IsUserLoggedIn(), ConfigurationPolicy.ErrorLog);
                            }
                            else if (!string.IsNullOrEmpty(result.LoginUserEmail))
                            {
                                overrideEmail = result.LoginUserEmail;
                            }
                            else
                            {
                                Log.Write("SitefinityHelper.IsUserLoggedIn() is false ", ConfigurationPolicy.ErrorLog);
                                overrideEmail = _jobApplicationService.GetOverrideEmail(ref status, ref applicantInfo, true);
                            }

                            Log.Write("overrideEmail is : " + overrideEmail, ConfigurationPolicy.ErrorLog);
                            if (overrideEmail != null && status == JobApplicationStatus.Available)
                            {
                                Log.Write("overrideEmail is in: ", ConfigurationPolicy.ErrorLog);

                                //Create Application
                                var response = CreateJobApplication(result, jobDetails, applicantInfo, overrideEmail);

                                if (response.MemberApplicationResponse.Success && response.MemberApplicationResponse.ApplicationID.HasValue)
                                {
                                    if (!response.FilesUploaded)
                                    {
                                        viewModel.Status  = response.Status; // Unable to attach files
                                        viewModel.Message = response.Message;
                                    }
                                    else
                                    {
                                        viewModel.Status  = response.Status;
                                        viewModel.Message = response.Message;
                                        if (!this.JobApplicationSuccessPageId.IsNullOrEmpty())
                                        {
                                            Log.Write("JobApplicationSuccessPageId is not null: ", ConfigurationPolicy.ErrorLog);
                                            var successPageUrl = SitefinityHelper.GetPageUrl(this.JobApplicationSuccessPageId);
                                            Log.Write("successPageUrl : " + successPageUrl, ConfigurationPolicy.ErrorLog);
                                            return(Redirect(successPageUrl));
                                        }
                                    }
                                }
                                else
                                {
                                    if (viewModel.Status == JobApplicationStatus.Already_Applied)
                                    {
                                        if (!jobDetails.JobSEOUrl.IsNullOrEmpty())
                                        {
                                            return(Redirect(string.Format("job-application/{0}/{1}?error=exists", jobDetails.JobSEOUrl, result.JobId.Value)));
                                        }
                                        else
                                        {
                                            return(Redirect(string.Format("job-application/{0}?error=exists", result.JobId.Value)));
                                        }
                                    }
                                    viewModel.Status  = response.Status;
                                    viewModel.Message = response.Message;
                                }
                            }
                            else
                            {
                                Log.Write("overrideEmail is null: ", ConfigurationPolicy.ErrorLog);

                                if (status == JobApplicationStatus.NotAbleToLoginCreatedUser)
                                {
                                    viewModel.Message = "Unable to process your job application. Please try logging in and re-apply for the job.";
                                }
                                else if (status == JobApplicationStatus.NotAbleToCreateUser)
                                {
                                    viewModel.Message = "Unable to create user. Please register from";
                                }

                                viewModel.Status = status;
                            }
                        }
                        else
                        {
                            Log.Write("_jobApplicationService is null", ConfigurationPolicy.ErrorLog);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Log.Write("Social Handler : Exception Caught" + ex.Message, ConfigurationPolicy.ErrorLog);
            }



            // To catch access denied error for seek
            int jobId;

            if (!string.IsNullOrEmpty(this.Request.QueryString["error"]) && this.Request.QueryString["error"].ToLower().Contains("denied") && state != null && int.TryParse(state, out jobId))
            {
                var jobDetails = GetJobDetails(jobId);
                if (!jobDetails.JobSEOUrl.IsNullOrEmpty())
                {
                    return(Redirect(string.Format("job-application/{0}/{1}?error=denied", jobDetails.JobSEOUrl, jobId)));
                }
                else
                {
                    return(Redirect(string.Format("job-application/{0}?error=resume", jobId)));
                }
            }


            if (!this.JobSearchResultsPageId.IsNullOrEmpty())
            {
                ViewBag.JobSearchResultsUrl = SitefinityHelper.GetPageUrl(this.JobSearchResultsPageId);
            }

            var fullTemplateName = this.templateNamePrefix + this.TemplateName;

            return(View(fullTemplateName, viewModel));
        }