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)); }
// 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); }
/// <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); }
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); }
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); }
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)); }
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)); }