public IActionResult Index() { var vm = new ResumeViewModel(); #region Fill data to viewmodel (if it's exist) // Get info about current user vm.UserInfo = _userInfo; var currentStudent = _studentService.GetCurrentStudentByUserInfo(vm.UserInfo.Id); //Get current Resume Id Resume resume = _resumeService.GetResumeByStudentId(currentStudent.Id); //create new resume if it doesn't exist if (resume == null) { _resumeService.CreateResumeForStudent(currentStudent.Id); } //Fill data to viewmodel int resumeId = _resumeService.GetResumeByStudentId(currentStudent.Id).Id; vm.ResumeId = resumeId; vm.CurrentResumeStep = _resumeService.GetResumeByStudentId(currentStudent.Id).CurrentStep; var stream = _streamService.GetStreamByStudentId(currentStudent.Id); if (stream != null) { vm.StreamFullName = stream.StreamFullName; } var summary = _summaryService.GetSummaryByResumeId(resumeId); if (summary != null) { vm.Summary = summary.Text; } string [] existingStudentsSkill = _skillService.GetAllSkillsForStudent(currentStudent.Id).ToArray(); if (existingStudentsSkill.Length != 0) { vm.Skills = _skillService.GetAllSkillsForStudent(currentStudent.Id).ToArray(); } else { //If Student hasn't skills in DB, get the default skills by stream vm.Skills = _skillService.GetDefaultSkillsByStream(stream.Id).ToArray(); } vm.ForeignLanguages = _languageService.GetAllForeignLanguagesForResume(resumeId).ToDictionary(x => x.LanguageId, x => x.LanguageLevelId); vm.Educations = _educationService.GetAllEducationsForResume(resumeId).ToArray(); vm.Courses = _courseService.GetAllCoursesForResume(resumeId).ToArray(); vm.Certificates = _certificateService.GetAllCertificatesForResume(resumeId).ToArray(); vm.Exams = _examService.GetAllExamsForResume(resumeId).ToArray(); WorkExperience[] workExperiences = _workExperienceService.GetWorkExperienceForResume(resumeId).ToArray(); vm.WorkExperiences = new WorkExperienceViewModel[workExperiences.Length]; if (workExperiences.Count() != 0) { for (int i = 0; i < workExperiences.Count(); i++) { vm.WorkExperiences[i] = new WorkExperienceViewModel(workExperiences[i]); } } vm.Portfolios = _portfolioService.GetPortfolioForResume(resumeId).ToArray(); vm.MilitaryStatus = _militaryStatusService.GetMilitaryStatusForResume(resumeId); vm.Recommendations = _recommendationService.GetAllRecommendationsForResume(resumeId).ToArray(); vm.AdditionalInfo = _additionalInfoService.GetAdditionalInfo(resumeId); #endregion #region Fill data to dropdown lists //Get all languages from table Languages List <Language> languages = _languageService.GetAllLanguages().ToList(); languages.Insert(0, languages.First(l => l.Name == "English")); var index = languages.FindLastIndex(l => l.Name == "English"); languages.RemoveAt(index); //Fill data to dropdownlist Languages vm.Languages = languages; //Get all language levels from table LanguageLevels List <LanguageLevel> languageLevels = _languageService.GetAllLanguageLevels().ToList(); languageLevels.Insert(0, new LanguageLevel { LevelName = "---", Id = 0 }); //Fill data to dropdownlist language levels vm.LanguageLevels = languageLevels; //Get all skills from table Skills vm.SkillList = _skillService.GetAllSkills().ToList(); //Get all Months, Years from DateService vm.Months = _dateService.GetAllMonths(); vm.Years = _dateService.GetAllYears().ToList(); //Fill data to dropdownlist Education Levels vm.EducationLevels = _educationService.GetEducationLevels().ToList(); #endregion //TODO: add more other statuses, when they will be implemented if (resume != null && resume.Status == ResumeStatuses.Submitted) { return(RedirectToAction(nameof(ResumeReviewController.Index), "ResumeReview", new { resumeId = resume.Id })); } else { return(View("Index", vm)); } }
public async Task <IActionResult> EditResume(int resumeId) { var student = _studentService.GetStudentByResumeId(resumeId); ResumeViewModel vm = new ResumeViewModel { ResumeId = resumeId, UserInfo = _userInfo, StreamFullName = _streamService.GetStreamByStudentId(student.Id).StreamFullName, Summary = _summaryService.GetSummaryByResumeId(resumeId).Text, Skills = _skillService.GetAllSkillsForStudent(student.Id).ToArray(), ForeignLanguages = _languageService.GetAllForeignLanguagesForResume(resumeId).ToDictionary(x => x.LanguageId, x => x.LanguageLevelId), Educations = _educationService.GetAllEducationsForResume(resumeId).ToArray(), Courses = _courseService.GetAllCoursesForResume(resumeId).ToArray(), Certificates = _certificateService.GetAllCertificatesForResume(resumeId).ToArray(), Exams = _examService.GetAllExamsForResume(resumeId).ToArray(), Portfolios = _portfolioService.GetPortfolioForResume(resumeId).ToArray(), MilitaryStatus = _militaryStatusService.GetMilitaryStatusForResume(resumeId), AdditionalInfo = _additionalInfoService.GetAdditionalInfo(resumeId), Recommendations = _recommendationService.GetAllRecommendationsForResume(resumeId).ToArray() }; WorkExperience[] workExperiences = _workExperienceService.GetWorkExperienceForResume(resumeId).ToArray(); vm.WorkExperiences = new WorkExperienceViewModel[workExperiences.Length]; if (workExperiences.Count() != 0) { for (int i = 0; i < workExperiences.Count(); i++) { vm.WorkExperiences[i] = new WorkExperienceViewModel(workExperiences[i]); } } #region Fill data to dropdown lists //Get all languages from table Languages List <Language> languages = _languageService.GetAllLanguages().ToList(); languages.Insert(0, languages.First(l => l.Name == "English")); var index = languages.FindLastIndex(l => l.Name == "English"); languages.RemoveAt(index); //Fill data to dropdownlist Languages vm.Languages = languages; //Get all language levels from table LanguageLevels List <LanguageLevel> languageLevels = _languageService.GetAllLanguageLevels().ToList(); languageLevels.Insert(0, new LanguageLevel { LevelName = "---", Id = 0 }); //Fill data to dropdownlist language levels vm.LanguageLevels = languageLevels; //Get all skills from table Skills vm.SkillList = _skillService.GetAllSkills().ToList(); //Get all Months, Years from DateService vm.Months = _dateService.GetAllMonths(); vm.Years = _dateService.GetAllYears().ToList(); //Fill data to dropdownlist Education Levels vm.EducationLevels = _educationService.GetEducationLevels().ToList(); #endregion return(View(vm)); }