public IActionResult Index() { if (IsWorker()) { return(Redirect("/WorkerManagement/Index")); } User user = this._userManager.GetUserAsync(HttpContext.User).Result; EmployerAccount employerAccount = _applicationDbContext. EmployerAccounts.Where(a => a.Id == user.EmployerAccountId). Include(a => a.CreatedJobs).First(); if (!employerAccount.CreatedJobs.Any(a => a.JobState == JobState.Hiring)) { ViewData["Jobs"] = "<h2>You have no active jobs!</h2>"; return(View()); } StringBuilder stringBuilder = new StringBuilder(); foreach (var job in employerAccount.CreatedJobs.Where(a => a.JobState == JobState.Hiring)) { stringBuilder.AppendLine("<li>"); stringBuilder.AppendLine("<a href=\"/ManageJob/Manage/" + job.Id + "\">" + job.Name + "</a>"); stringBuilder.AppendLine("</li>"); } ViewData["Jobs"] = stringBuilder.ToString(); return(View()); }
public ActionResult Join(LinkedInJoin joinModel, [Bind(Include = "AcceptTerms")] CheckBoxValue acceptTerms) { var profile = _linkedInQuery.GetProfile(CurrentAnonymousUser.Id); if (profile == null) { return(RedirectToRoute(HomeRoutes.Home)); } try { joinModel = joinModel ?? new LinkedInJoin(); // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, new StandardErrorHandler()); } // Try to join. if (acceptTerms != null && acceptTerms.IsChecked) { var account = new EmployerAccount { FirstName = joinModel.FirstName, LastName = joinModel.LastName, EmailAddress = joinModel.EmailAddress, PhoneNumber = joinModel.PhoneNumber, OrganisationName = joinModel.OrganisationName, Location = joinModel.Location, SubRole = joinModel.SubRole, IndustryIds = joinModel.IndustryIds }; _accountsManager.Join(HttpContext, account, profile); return(RedirectToReturnUrl()); } // Not accepting terms so cannot proceed but also check whether any other fields fail validation. joinModel.Prepare(); joinModel.Validate(); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(View("Account", GetAccountModel(joinModel))); }
protected ActionResult TryJoin(EmployerJoin join, CheckBoxValue acceptTerms, Func <IErrorHandler> createErrorHandler) { try { join = join ?? new EmployerJoin(); // Process the post to check validations. if (acceptTerms == null || !acceptTerms.IsChecked) { ModelState.AddModelError(new[] { new TermsValidationError("AcceptTerms") }, createErrorHandler()); } // Try to join. if (acceptTerms != null && acceptTerms.IsChecked) { var account = new EmployerAccount { FirstName = join.FirstName, LastName = join.LastName, OrganisationName = join.OrganisationName, EmailAddress = join.EmailAddress, PhoneNumber = join.PhoneNumber, SubRole = join.SubRole, Location = join.Location, IndustryIds = join.IndustryIds, }; var credentials = new AccountLoginCredentials { LoginId = join.JoinLoginId, Password = join.JoinPassword, ConfirmPassword = join.JoinConfirmPassword, }; _accountsManager.Join(HttpContext, account, credentials); return(RedirectToReturnUrl()); } // Not accepting terms so cannot proceed but also check whether any other fields fail validation. join.Prepare(); join.Validate(); } catch (UserException ex) { ModelState.AddModelError(ex, createErrorHandler()); } return(null); }
/// <summary> /// This creates an account in the job posting /// </summary> /// <param name="username">Name of user</param> /// <param name="password">Password of user</param> /// <param name="companyName">Company of user</param> /// <param name="email">Email of user</param> /// <param name="phone">Phone of user</param> /// <returns></returns> public static EmployerAccount CreateEmployerAccount(string username, string password, string companyName, string email, int phone) { var employerAccount = new EmployerAccount { Username = username, Password = password, CompanyName = companyName, Email = email, Phone = phone, }; employerAccounts.Add(employerAccount); return(EmployerAccount); }
public IActionResult OnGet() { User currentUser = _userManager.GetUserAsync(HttpContext.User).Result; if (currentUser.EmployerAccountId != null) { EmployerAccount employerAccount = _applicationDbContext.EmployerAccounts. First(a => a.Id == currentUser.EmployerAccountId); employerAccount.UserId = currentUser.Id; } else { WorkerAccount workerAccount = _applicationDbContext.WorkerAccounts. First(a => a.Id == currentUser.WorkerAccountId); workerAccount.UserId = currentUser.Id; } _applicationDbContext.SaveChanges(); return(Redirect("/")); }
public ActionResult Join(EmployerJoinModel joinModel) { try { joinModel.Validate(); // Try to join. var account = new EmployerAccount { FirstName = joinModel.FirstName, LastName = joinModel.LastName, EmailAddress = joinModel.EmailAddress, Location = joinModel.Location, OrganisationName = joinModel.OrganisationName, PhoneNumber = joinModel.PhoneNumber, SubRole = joinModel.SubRole, }; var credentials = new AccountLoginCredentials { LoginId = joinModel.LoginId, Password = joinModel.Password, ConfirmPassword = joinModel.Password, }; _accountsManager.Join(HttpContext, account, credentials); return(Json(new JsonResponseModel())); } catch (DuplicateUserException ex) { ModelState.AddModelError("LoginId", ex.Message); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
private Employer CreateEmployer(EmployerJoin join) { var account = new EmployerAccount { FirstName = join.FirstName, LastName = join.LastName, EmailAddress = join.EmailAddress, PhoneNumber = join.PhoneNumber, OrganisationName = join.OrganisationName, Location = join.Location, SubRole = join.SubRole, IndustryIds = join.IndustryIds }; var credentials = new AccountLoginCredentials { LoginId = join.JoinLoginId, Password = join.JoinPassword, ConfirmPassword = join.JoinConfirmPassword, }; return(_accountsManager.Join(HttpContext, account, credentials)); }
public IActionResult Index() { if (IsWorker()) { return(Redirect("/WorkerManagement/Index")); } User user = this._userManager.GetUserAsync(HttpContext.User).Result; EmployerAccount employerAccount = _applicationDbContext. EmployerAccounts.Where(a => a.Id == user.EmployerAccountId). Include(a => a.CreatedJobs).First(); YourActiveJobsViewModel model = new YourActiveJobsViewModel(); model.AnyActiveJobs = employerAccount.CreatedJobs.Any(a => a.JobState == JobState.Hiring || a.JobState == JobState.Hired); if (!model.AnyActiveJobs) { return(View(model)); } model.ActiveJobs = employerAccount.CreatedJobs.Where(a => a.JobState == JobState.Hiring || a.JobState == JobState.Hired); return(View(model)); }