public async Task <ActionResult> JobOfferList(JobOfferListModel model) { if (!model.ApplyFavorite) { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); if (model.ApplyKeywords) { model.Filter.KeywordNumbers = applicant.KeywordNumbers; } var result = await JobOfferFacade.GetJobOffersAsync(model.Filter); model.JobOffers = new List <JobOfferDto>(result.Items); } else { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); var result = await JobOfferFacade.GetFavoriteJobOffersAsync(applicant.Id); model = new JobOfferListModel { JobOffers = new List <JobOfferDto>(result.Items), ApplyFavorite = true }; } return(View(model)); }
public async Task <ActionResult> Login(LoginModel model, string returnUrl) { //tady to chce vyladit mužu jít přes applicantFacade / companyFacade - stejná věc na 2 místech (bool success, string roles) = await ApplicantFacade.Login(model.Username, model.Password); if (success) { var authTicket = new FormsAuthenticationTicket(1, model.Username, DateTime.Now, DateTime.Now.AddMinutes(30), false, roles); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); var decodedUrl = ""; if (!string.IsNullOrEmpty(returnUrl)) { decodedUrl = Server.UrlDecode(returnUrl); } if (Url.IsLocalUrl(decodedUrl)) { return(Redirect(decodedUrl)); } if (roles == "Applicant") { return(RedirectToAction("Index", "Applicant")); } return(RedirectToAction("Index", "Company")); } ModelState.AddModelError("", "Wrong username or password!"); return(View()); }
public async Task <ActionResult> ChangeApplicantInformation(ApplicantEditModel model) { await ApplicantFacade.EditApplicantAsync(model.Applicant); await ApplicantFacade.EditApplicantsKeywordsAsync(model.Applicant.Id, model.Keywords); return(RedirectToAction("Index", "Applicant")); }
public async Task <ActionResult> FavoriteJobDelete(Guid jobOfferId) { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); Guid favoriteJobId = await JobOfferFacade.GetFavoriteByApplicantAndOffer(applicant.Id, jobOfferId); await JobOfferFacade.DeleteFavoriteJobOfferAsync(favoriteJobId); return(RedirectToAction("JobOfferList", "Applicant")); }
public async Task <ActionResult> ApplicantList() { var result = await ApplicantFacade.GetAllApplicantsAsync(); var model = new ApplicantListModel { Applicants = new List <ApplicantDto>(result.Items) }; return(View(model)); }
public async Task <ActionResult> FavoriteJobCreate(Guid jobOfferId) { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); var favoriteJob = new FavoriteJobDto { JobOfferId = jobOfferId, ApplicantId = applicant.Id }; await JobOfferFacade.CreateFavoriteJobAsync(favoriteJob); return(RedirectToAction("JobOfferList", "Applicant")); }
public async Task <ActionResult> JobOfferDetail(Guid id) { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); var model = new JobOfferDetailModel { JobOffer = await JobOfferFacade.GetJobOfferAsync(id), AlreadyApplied = await ApplicationFacade.CheckIfApplied(applicant.Id, id), AlreadyFavorite = await JobOfferFacade.CheckIfFavorite(applicant.Id, id) }; return(View(model)); }
public async Task <ActionResult> ApplicantList(ApplicantListModel model) { model.Filter = new ApplicantFilterDto(); if (model.Keyword != null) { model.Filter.KeywordNumbers = new[] { (int)model.Keyword }; } var result = await ApplicantFacade.GetApplicantsAsync(model.Filter); model.Applicants = new List <ApplicantDto>(result.Items); return(View(model)); }
public async Task <ActionResult> ChangeApplicantInformation() { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); var model = new ApplicantEditModel { Applicant = applicant, Keywords = new List <bool>() }; for (int i = 0; i < Enum.GetNames(typeof(Keyword)).Length; i++) { model.Keywords.Add(applicant.KeywordNumbers.Contains(i)); } return(View(model)); }
public async Task <ActionResult> ApplicationList() { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); var filter = new ApplicationFilterDto { ApplicantId = applicant.Id }; var result = await ApplicationFacade.GetApplicationsAsync(filter); var model = new ApplicationListModel { Filter = filter, Applications = new List <ApplicationDto>(result.Items), ApplicantId = applicant.Id }; return(View(model)); }
public async Task <ActionResult> ApplicationCreate(ApplicationDto model) { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); model.ApplicantId = applicant.Id; model.State = ApplicationState.Undecided; await ApplicationFacade.CreateApplicationAsync(model); Guid favoriteJobId = await JobOfferFacade.GetFavoriteByApplicantAndOffer(applicant.Id, model.JobOfferId); if (favoriteJobId != Guid.Empty) { await JobOfferFacade.DeleteFavoriteJobOfferAsync(favoriteJobId); } return(RedirectToAction("ApplicationList", "Applicant")); }
public async Task <ActionResult> RegisterApplicant(UserApplicantCreateDto userApplicantCreateDto) { try { await ApplicantFacade.RegisterApplicant(userApplicantCreateDto); //FormsAuthentication.SetAuthCookie(userCreateDto.Username, false); var authTicket = new FormsAuthenticationTicket(1, userApplicantCreateDto.Username, DateTime.Now, DateTime.Now.AddMinutes(30), false, ""); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); return(RedirectToAction("Index", "Applicant")); } catch (ArgumentException) { ModelState.AddModelError("Username", "Account with that username already exists!"); return(View()); } }
public async Task <ActionResult> Index() { var applicant = await ApplicantFacade.GetApplicantAccordingToUsernameAsync(User.Identity.Name); return(View(applicant)); }
public async Task <ActionResult> ApplicantDetail(Guid id) { var model = await ApplicantFacade.GetApplicantAsync(id); return(View(model)); }