// GET: Vacancies/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var vacancy = await _context.Vacancies.FindAsync(id); if (vacancy == null) { return(NotFound()); } List <int> skillIds = _context.ObjectSkills .Where(os => os.ObjectId == vacancy.Id) .Where(os => os.ObjectTypeId == (int)ObjectTypeEnum.Vakance).Select(o => o.Id) .ToList(); VacancyViewModel vacancyViewModel = new VacancyViewModel { Name = vacancy.Name, OpeningDate = vacancy.OpeningDate, ClosingDate = vacancy.ClosingDate, TestId = vacancy.TestId, Test = vacancy.Test, CandidateCount = _context.Candidates.Where(c => c.VacancyId == vacancy.Id).Count(), Skills = _context.Skills.Where(s => skillIds.Contains(s.Id)).ToList(), }; ViewData["TestId"] = new SelectList(_context.Tests, "Id", "Name"); return(View(vacancyViewModel)); }
public ActionResult Create(VacancyViewModel viewModel) { try { if (!ModelState.IsValid) { return(View(viewModel)); } var vacancy = new VacancyDTO { VacancyName = viewModel.VacancyName, VacancyDescript = viewModel.VacancyDescript, CustomerId = viewModel.CustomerId, CategoryId = viewModel.CategoryId }; vacancyService.AddVacancy(vacancy); return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError("", e.Message); } return(View(viewModel)); }
public ActionResult Create(VacancyViewModel viewModel) { try { if (ModelState.IsValid) { var vacancy = Mapper.Map <VacancyViewModel, Vacancy>(viewModel); vacancy.Technologies = viewModel.TechnologiesIds != null? _technologyService.GetByIds(viewModel.TechnologiesIds) : new List <Technology>(); _vacancyService.Insert(vacancy); viewModel.Locales.ToList().ForEach(l => { _localizedEntityService.SaveLocalizedValue(vacancy, e => e.Title, l.Title, l.LanguageId); _localizedEntityService.SaveLocalizedValue(vacancy, e => e.ShortDescription, l.ShortDescription, l.LanguageId); _localizedEntityService.SaveLocalizedValue(vacancy, e => e.Bonuses, l.Bonuses, l.LanguageId); _localizedEntityService.SaveLocalizedValue(vacancy, e => e.Requirments, l.Requirments, l.LanguageId); _localizedEntityService.SaveLocalizedValue(vacancy, e => e.Responsibilities, l.Responsibilities, l.LanguageId); _localizedEntityService.SaveLocalizedValue(vacancy, e => e.WeOffer, l.WeOffer, l.LanguageId); }); return(RedirectToAction("Index")); } } catch (Exception e) { ModelState.AddModelError("", e.Message); viewModel.TechnologiesSelectList = Mapper.Map <List <Technology>, List <SelectListItem> >(_technologyService.GetAll()); } return(View(viewModel)); }
public void ShouldReturnOnlineVacancyOkIfCalledFromTheSaveAndContinueActionAndTheVacancyIsAnOnlineOne() { var newVacancyViewModel = new VacancyViewModel { NewVacancyViewModel = new NewVacancyViewModel { OfflineVacancy = false } }; var vacancyRequirementsAndProspects = new VacancyRequirementsProspectsViewModel(); VacancyPostingProvider.Setup(p => p.GetVacancy(_viewModel.VacancyReferenceNumber)) .Returns(newVacancyViewModel); VacancyPostingProvider.Setup(p => p.UpdateVacancy(It.IsAny <VacancyRequirementsProspectsViewModel>())) .Returns(vacancyRequirementsAndProspects); var mediator = GetMediator(); var result = mediator.UpdateVacancy(_viewModel); result.Should() .Match( (MediatorResponse <VacancyRequirementsProspectsViewModel> p) => p.Code == VacancyPostingMediatorCodes.UpdateVacancy.OnlineVacancyOk); }
public void ShouldNotShowHoursPerWeekWhenApprenticeshipHasNoHoursPerWeekSet(double?hoursPerWeek, bool expectValid) { //Arrange var viewModel = new VacancyViewModel() { ProviderSite = new ProviderSiteViewModel() { Address = new AddressViewModel() }, FurtherVacancyDetailsViewModel = new FurtherVacancyDetailsViewModel { VacancyDatesViewModel = new VacancyDatesViewModel { ClosingDate = new DateViewModel(DateTime.Now), PossibleStartDate = new DateViewModel(DateTime.Now) }, VacancyType = VacancyType.Apprenticeship, Wage = new WageViewModel() { HoursPerWeek = (decimal?)hoursPerWeek } }, NewVacancyViewModel = new NewVacancyViewModel { VacancyOwnerRelationship = new VacancyOwnerRelationshipViewModel() { Employer = new EmployerViewModel() { Address = new AddressViewModel() } }, LocationAddresses = new List <VacancyLocationAddressViewModel>(), OfflineVacancy = false }, TrainingDetailsViewModel = new TrainingDetailsViewModel(), VacancyQuestionsViewModel = new VacancyQuestionsViewModel(), VacancyRequirementsProspectsViewModel = new VacancyRequirementsProspectsViewModel(), Status = VacancyStatus.ReservedForQA, VacancyType = VacancyType.Apprenticeship }; var details = new WorkingWeekAndWage(); //Act var view = details.RenderAsHtml(viewModel); //Assert var totalHoursPerWeek = view.GetElementbyId("total-hours-per-week"); if (expectValid) { totalHoursPerWeek.Should().NotBeNull(); } else { totalHoursPerWeek.Should().BeNull(); } }
public async Task <IActionResult> GetSitemap() { var page = 1; var key = "sitemap"; var xml = _cache.Get(key)?.ToString(); if (string.IsNullOrEmpty(xml)) { IPagedList <Publication> publications; IPagedList <Vacancy> vacancies; var sitemap = new Sitemap(); var events = GetCustomPages(); foreach (var url in events) { sitemap.Add(CreateUrl(url)); } page = 1; do { publications = await _publicationService.GetPublications(null, page); page++; foreach (var p in publications) { var publication = new PublicationViewModel(p, _settings.WebSiteUrl); sitemap.Add(CreateUrl(publication.ShareUrl.ToString())); } }while (publications.HasNextPage); page = 1; do { vacancies = await _vacancyService.GetVacancies(page); page++; foreach (var v in vacancies) { var vacancy = new VacancyViewModel(v, _settings.WebSiteUrl); sitemap.Add(CreateUrl(vacancy.ShareUrl.ToString())); } }while (vacancies.HasNextPage); xml = sitemap.ToXml(); _cache.Set(key, xml, TimeSpan.FromMinutes(10)); } return(Content(xml, "application/xml")); }
public ActionResult Create() { ViewBag.CategoryId = new SelectList(categoryService.GetCategories(), "CategoryId", "CategoryName"); ViewBag.CustomerId = new SelectList(customService.GetCustomers(), "CustomerId", "CustomerFirstName"); var newVacancy = new VacancyViewModel(); return(View(newVacancy)); }
public async Task <IActionResult> Index(VacancyViewModel vacancyViewModel) { vacancyViewModel.Vacancies = await _unitOfWork.Vacancy.GetAllAsync(vacancyViewModel.Search.ToLower()); await _unitOfWork.Vacancy.InsertRangeAsync(vacancyViewModel.Vacancies); await _unitOfWork.SaveAsync(); return(View(vacancyViewModel)); }
/// <summary> /// Метод для создания новой вакансии /// </summary> /// <returns></returns> public ActionResult CreateVacancy() { var model = new VacancyViewModel { Experience = GetExperienceLists(), Company = GetCompanies() }; return(View(model)); }
public async Task <IActionResult> Index(string uid) { VacancyViewModel model = new VacancyViewModel(); VacancyProvider vacancyProvider = new VacancyProvider(); var curVac = await vacancyProvider.GetVacancyByUidAsync(new Guid(uid)); model.CurrentVacancy = curVac; return(View(model)); }
public ActionResult AddEditPosting(int id = 0) { var model = new VacancyViewModel(); model.Vacancy = _context.vacancies.Where(x => x.id == id).FirstOrDefault() ?? new vacancy(); model.job_type = _context.job_types.ToList(); model.experience_levels = _context.experience_levels.OrderBy(x => x.id).ToList(); model.education_levels = _context.education_levels.ToList(); return(View(model)); }
public ActionResult AddVacancy() { var vacancyViewModel = new VacancyViewModel() { ViewModelTitle = "Создать вакансию", AddButtonTitle = "Add", RedirectUrl = Url.Action("Index", "Student") }; return(View(vacancyViewModel)); }
public async Task <IActionResult> Index() { VacancyViewModel vacancyViewModel = new VacancyViewModel() { Vacancies = await _unitOfWork.Vacancy.GetAllAsync("") }; await _unitOfWork.Vacancy.InsertRangeAsync(vacancyViewModel.Vacancies); await _unitOfWork.SaveAsync(); return(View(vacancyViewModel)); }
public async Task <IActionResult> GetSitemap() { var page = 1; var key = "sitemap"; var xml = _cache.Get(key)?.ToString(); if (string.IsNullOrEmpty(xml)) { IPagedList <Publication> publications; IPagedList <Vacancy> vacancies; var sitemap = new Sitemap(); sitemap.Add(CreateUrl(Settings.Current.WebSiteUrl)); sitemap.Add(CreateUrl(Settings.Current.WebSiteUrl + "partners/")); page = 1; do { publications = await _publicationManager.GetPublications(null, page); page++; foreach (var p in publications) { var publication = new PublicationViewModel(p, Settings.Current.WebSiteUrl); sitemap.Add(CreateUrl(publication.ShareUrl)); } }while (publications.HasNextPage); page = 1; do { vacancies = await _vacancyManager.GetVacancies(page); page++; foreach (var v in vacancies) { var vacancy = new VacancyViewModel(v, Settings.Current.WebSiteUrl); sitemap.Add(CreateUrl(vacancy.ShareUrl)); } }while (vacancies.HasNextPage); xml = sitemap.ToXml(); _cache.Set(key, xml, TimeSpan.FromMinutes(10)); } return(Content(xml, Sitemap.MimeType)); }
private void UpdateModel(VacancyViewModel vacancyViewModel, Vacancy vacancy) { if (vacancy == null) { return; } vacancy.Title = vacancyViewModel.Title; vacancy.Description = vacancyViewModel.Description; vacancy.Salary = vacancyViewModel.Salary; vacancy.IsOpened = vacancyViewModel.IsOpened; vacancy.Requirements = vacancyViewModel.Requirements; }
public ActionResult Delete(int id, VacancyViewModel viewModel) { try { vacancyService.DeleteVacancy(id); return(RedirectToAction("Index")); } catch { ModelState.AddModelError("", "An error has occured. This Employee was not deleted."); } return(View(viewModel)); }
// GET: Admin/Vacancy/Create public ActionResult Create() { var viewModel = new VacancyViewModel { CreatedDate = DateTime.Now, }; viewModel.TechnologiesSelectList = Mapper.Map <List <Technology>, List <SelectListItem> >(_technologyService.GetAll()); AddLocales(viewModel.Locales, (locale, languageId) => { }); return(View(viewModel)); }
public VacancyViewModel Build() { var viewModel = new VacancyViewModel { NewVacancyViewModel = _newVacancyViewModel, TrainingDetailsViewModel = _trainingDetailsViewModel, FurtherVacancyDetailsViewModel = _furtherVacancyDetailsViewModel, VacancyRequirementsProspectsViewModel = _vacancyRequirementsProspectsViewModel, VacancyQuestionsViewModel = _vacancyQuestionsViewModel }; return(viewModel); }
public async Task <IActionResult> Create(VacancyViewModel VacancyViewModel) { if (ModelState.IsValid) { Vacancy vacancy = new Vacancy { Name = VacancyViewModel.Name, OpeningDate = VacancyViewModel.OpeningDate, ClosingDate = VacancyViewModel.ClosingDate, TestId = VacancyViewModel.TestId, Test = VacancyViewModel.Test, }; _context.Add(vacancy); await _context.SaveChangesAsync(); foreach (var item in VacancyViewModel.Skills) { if (string.IsNullOrEmpty(item.Value)) { continue; } Skill skill = new Skill { Value = item.Value, SkillTypeId = item.SkillTypeId, }; _context.Add(skill); await _context.SaveChangesAsync(); int vacancyId = vacancy.Id; int skillId = skill.Id; ObjectSkill objectSkill = new ObjectSkill { ObjectId = vacancyId, ObjectTypeId = (int)ObjectTypeEnum.Vakance, SkillId = skillId, }; _context.Add(objectSkill); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } ViewData["TestId"] = new SelectList(_context.Tests, "Id", "Name"); ViewData["SkillTypeName"] = new SelectList(_context.SkillTypes, "Id", "Name"); return(View(VacancyViewModel)); }
public async Task <IActionResult> Edit(int id, VacancyViewModel vacancy) { if (id != vacancy.Id) { return(NotFound()); } ViewData["TestId"] = new SelectList(_context.Tests, "Id", "Name"); if (ModelState.IsValid) { try { _context.Update(vacancy); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VacancyExists(vacancy.Id)) { return(NotFound()); } else { throw; } } foreach (var item in vacancy.Skills) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SkillExists(item.Id)) { return(NotFound()); } else { throw; } } } return(RedirectToAction(nameof(Index))); } return(View(vacancy)); }
public async Task <IActionResult> VacancyEdit(int?id, string name) { VacancyViewModel model = new VacancyViewModel(); int projectId = 0; // А работает ли так - хз ваще! await TryUpdateModelAsync(model, "", i => i.Vacancy, i => i.Applicant, i => i.UsersSelectList, i => i.Competences); projectId = model.Vacancy.ProjectId; if (projectId == 0) { ModelState.AddModelError("Error", "Ошибка с прикреплением вакансии к проекту"); } if (!ModelState.IsValid) { return(View(model)); } using var db = AppContextFactory.DB; using var t = db.Database.BeginTransaction(); try { // Редактируем вакансию. var vacancy = db.Vacancies.FirstOrDefault(i => i.Id == id) ?? new Vacancy(); vacancy.UserInfoId = model.Applicant.Id; vacancy.Name = model.Vacancy.Name; vacancy.ProjectId = model.Vacancy.ProjectId; if (vacancy.Id == 0) { db.Entry(vacancy).State = EntityState.Added; } await db.SaveChangesAsync(); await t.CommitAsync(); } catch (Exception ex) { await t.RollbackAsync(); ModelState.AddModelError("Error", "В процессе сохранения произошла ошибка! Ошибка: " + ex.Message); } return(RedirectToAction("Details", new { id = projectId })); }
/// <inheritdoc/> public string DeleteVacancy() { var selectedVacancy = new VacancyViewModel()?.SelectedVacancy; if (selectedVacancy != null) { using (var context = new DataBaseContext()) { context.VacancyModels.Remove(selectedVacancy); } return("Вакансия удалена."); } return("Вакансия не удалена, попробуйте позжею."); }
public async Task <ActionResult> EditVacancy(int id) { var vacancyViewModel = new VacancyViewModel() { ViewModelTitle = "Создать вакансию", AddButtonTitle = "Edit", RedirectUrl = Url.Action("Index", "Student") }; var vacancy = await repository.GetByIdAsync(id); UpdateModel(vacancyViewModel, vacancy); return(View(vacancyViewModel)); }
public async Task <ResponseMessageResult <string> > CreateVacancyAsync(VacancyViewModel vacancy) { var response = new ResponseMessageResult <string>(); var newVacancy = _mapper.Map <Vacancy>(vacancy); await _vacancyRepository.AddAsync(newVacancy); await _unitOfWork.SaveChangesAsync(); response.Content = vacancy.Id.ToString(); response.Message = $"Vacancy [{vacancy.Name}] Id: [{vacancy.Id}] was successfully added"; return(response); }
// GET: Vacancies public async Task <IActionResult> Index(string id) { if (!string.IsNullOrEmpty(id)) { List <Vacancy> vacancies = await _context.Vacancies.Where(v => v.Name.Contains(id.ToLower())).ToListAsync(); List <VacancyViewModel> vacancyViewModels = new List <VacancyViewModel>(); foreach (var vacancy in vacancies) { VacancyViewModel vacancyViewModel = new VacancyViewModel { Id = vacancy.Id, Name = vacancy.Name, OpeningDate = vacancy.OpeningDate, ClosingDate = vacancy.ClosingDate, Test = vacancy.Test, TestId = vacancy.TestId, CandidateCount = _context.Candidates.Where(c => c.VacancyId == vacancy.Id).Count(), }; vacancyViewModels.Add(vacancyViewModel); } return(View(vacancyViewModels)); } List <Vacancy> vacancies1 = await _context.Vacancies.ToListAsync(); List <VacancyViewModel> vacancyViewModels1 = new List <VacancyViewModel>(); foreach (var vacancy in vacancies1) { VacancyViewModel vacancyViewModel = new VacancyViewModel { Id = vacancy.Id, Name = vacancy.Name, OpeningDate = vacancy.OpeningDate, ClosingDate = vacancy.ClosingDate, Test = vacancy.Test, TestId = vacancy.TestId, CandidateCount = _context.Candidates.Where(c => c.VacancyId == vacancy.Id).Count(), }; vacancyViewModels1.Add(vacancyViewModel); } return(View(vacancyViewModels1)); }
public ActionResult CreateVacancy(VacancyViewModel model) { if (ModelState.IsValid) { List <long> IdList = new List <long>(); if (model.NewExperience != null) { IdList.AddRange(experienceRepository.CreateNewExperience(model.NewExperience)); } if (model.NewExperience == null && model.SelectedExperience == null) { IdList.AddRange(experienceRepository.CreateNewExperience("Без опыта")); } if (model.SelectedExperience != null) { foreach (var e in model.SelectedExperience) { IdList.Add(Convert.ToInt64(e)); } } var vacancy = new Vacancy { Ends = model.Ends, Starts = model.Starts, VacancyName = model.Name, Status = Status.Active, VacancyDescription = model.Description, Company = companyRepository.Load(long.Parse(model.SelectedCompany)), Requirements = experienceRepository.GetSelectedExperience(IdList) }; try { var id = employerRepository.SaveWProcedure(vacancy, Convert.ToInt64(User.Identity.GetUserId())); vacancy = employerRepository.Load(id); vacancy.Requirements = experienceRepository.GetSelectedExperience(IdList); employerRepository.Save(vacancy); return(RedirectToAction("Main", "employer")); } catch { return(RedirectToAction("Main", "employer")); } } else { return(RedirectToAction("Main")); } }
public void ShouldReturnAMessageIfTheVacancyReturnedIsNull() { const int vacancyReferenceNumber = 1; VacancyViewModel viewModel = null; var provider = new Mock<IVacancyQAProvider>(); provider.Setup(p => p.ReviewVacancy(vacancyReferenceNumber)).Returns(viewModel); var mediator = new VacancyMediatorBuilder().With(provider).Build(); var result = mediator.ReviewVacancy(vacancyReferenceNumber); result.AssertMessage(VacancyMediatorCodes.ReviewVacancy.InvalidVacancy, VacancyViewModelMessages.InvalidVacancy, UserMessageLevel.Error); }
protected void SetLinks(VacancyViewModel vacancyViewModel) { vacancyViewModel.BasicDetailsLink = Url.RouteUrl(ManagementRouteNames.BasicDetails, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); vacancyViewModel.TrainingDetailsLink = Url.RouteUrl(ManagementRouteNames.TrainingDetails, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); vacancyViewModel.SummaryLink = Url.RouteUrl(ManagementRouteNames.Summary, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); vacancyViewModel.RequirementsProspectsLink = Url.RouteUrl(ManagementRouteNames.RequirementsAndProspoects, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); vacancyViewModel.QuestionsLink = Url.RouteUrl(ManagementRouteNames.Questions, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); vacancyViewModel.EmployerLink = Url.RouteUrl(ManagementRouteNames.EmployerInformation, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); vacancyViewModel.LocationsLink = Url.RouteUrl(ManagementRouteNames.AddLocations, new { vacancyReferenceNumber = vacancyViewModel.VacancyReferenceNumber }); }
public async Task <ActionResult> SaveVacacny(VacancyViewModel vacancyViewModel, string redirectUrl) { if (!ModelState.IsValid) { return(View(vacancyViewModel)); } var vacancy = await repository.GetByIdAsync(vacancyViewModel.Id); if (vacancy != null) { UpdateModel(vacancyViewModel, vacancy); await repository.UpdateAsync(vacancy); } return(RedirectToLocal(redirectUrl)); }
public void ShouldReturnAMessageIfNoVacancyIsAvailable() { const int vacancyReferenceNumber = 1; VacancyViewModel viewModel = null; var provider = new Mock <IVacancyQAProvider>(); provider.Setup(p => p.ReserveVacancyForQA(vacancyReferenceNumber)).Returns(viewModel); var mediator = new VacancyMediatorBuilder().With(provider).Build(); var result = mediator.ReserveVacancyForQA(vacancyReferenceNumber); result.AssertMessage(VacancyMediatorCodes.ReserveVacancyForQA.NoVacanciesAvailable, "All vacancies have been reviewed.", UserMessageLevel.Info); result.ViewModel.Should().BeNull(); }