// todo ResponseToResumeSubmit click on button in AboutResume public ActionResult ResponseToResumeSubmit(Guid resumeId, Guid VacancyId) { // Identity User var userIdentity = HttpContext.User.Identity.Name; var user = dbContext.ApplicationUsers .Include(u => u.Employer).FirstOrDefault(u => u.Email == userIdentity); var resume = dbContext.Resumes.Include(r => r.Candidate.AccountUser) .Include(r => r.Candidate.Resumes) .Include(r => r.Candidate.AccountUser.Employer.Vacancies) .FirstOrDefault(r => r.Id == resumeId); var candidate = dbContext.Candidates.Include(c => c.Resumes) .FirstOrDefault(c => c.Resumes.Where(r => r.Id == resumeId) != null); if (user.Employer != null) { ResponseToResume newResponseToResume = new ResponseToResume(); newResponseToResume.Id = Guid.NewGuid(); newResponseToResume.Resume = resume; // todo ????????? ++ Vacancy var vac = dbContext.Vacancies.FirstOrDefault(v => v.Id == VacancyId); newResponseToResume.Vacancy = vac; newResponseToResume.DataResponse = DateTime.Now; dbContext.ResponsesToResume.Add(newResponseToResume); dbContext.SaveChanges(); } var res = new ResultStatusHelper(true) { Message = $"Отклик добавлен ", }; return(Ok(res)); }
// Todo saveVacancy click on button in AboutVacancy public ActionResult SaveVacancySubmit(Guid vacancyId) { // Identity User var userIdentity = HttpContext.User.Identity.Name; var user = dbContext.ApplicationUsers .Include(u => u.Employer).FirstOrDefault(u => u.Email == userIdentity); var candidate = dbContext.Candidates .Include(c => c.AccountUser) .FirstOrDefault(c => c.AccountUser.Email == userIdentity); var vacancy = dbContext.Vacancies.Include(v => v.Employer.AccountUser.Candidate.Resumes) .Include(v => v.Employer.Vacancies) .FirstOrDefault(v => v.Id == vacancyId); if (candidate != null) { SavedVacancy newSavedVacancy = new SavedVacancy(); newSavedVacancy.Id = Guid.NewGuid(); newSavedVacancy.Candidate = candidate; newSavedVacancy.Vacancy = vacancy; newSavedVacancy.DateSaved = DateTime.Now; dbContext.SavedVacancies.Add(newSavedVacancy); dbContext.SaveChanges(); } var res = new ResultStatusHelper(true) { Message = $"Вакансия сохранена ", }; return(RedirectToAction(nameof(AboutVacancy), new { vacancyId = vacancy.Id })); }
// Todo saveResume click on button in AboutResume public ActionResult SaveResumeSubmit(Guid resumeId) { // Identity User var userIdentity = HttpContext.User.Identity.Name; var user = dbContext.ApplicationUsers .Include(u => u.Employer).FirstOrDefault(u => u.Email == userIdentity); var resume = dbContext.Resumes.Include(r => r.Candidate.AccountUser) .Include(r => r.Candidate.Resumes) .Include(r => r.Candidate.AccountUser.Employer.Vacancies) .FirstOrDefault(r => r.Id == resumeId); if (user?.Employer != null) { SavedResume newSavedResume = new SavedResume(); newSavedResume.Id = Guid.NewGuid(); newSavedResume.Resume = resume; newSavedResume.Employer = user.Employer; newSavedResume.DateSaved = DateTime.Now; dbContext.SavedResumes.Add(newSavedResume); dbContext.SaveChanges(); } var res = new ResultStatusHelper(true) { Message = $"Resume сохранено", }; return(Ok(res)); }