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")); } }