public static async void InitDb() { var db = new VacancyContext(); var vacanciesRequestResult = await HhApiHelper.GetVacancies("", 0, 50); if (vacanciesRequestResult != null) { foreach (var vacancy in vacanciesRequestResult.Vacancies) { var vacancyInDb = db.Vacancies.Find(vacancy.Id); if (vacancyInDb == null) { db.Vacancies.Add(vacancy); } else { vacancyInDb.Salary = vacancy.Salary; vacancyInDb.Title = vacancy.Title; vacancyInDb.Url = vacancy.Url; vacancyInDb.Description = vacancy.Description; vacancyInDb.EmployerName = vacancy.EmployerName; } } await db.SaveChangesAsync(); } }
public VacancyController(VacancyContext context) { db = context; }
public ApplicationViewModel() { db = new VacancyContext(); db.Vacancies.Load(); Vacancies = db.Vacancies.Local.ToBindingList(); }
public VacancyItemsController(VacancyContext context) { _context = context; }