Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
 public VacancyController(VacancyContext context)
 {
     db = context;
 }
Esempio n. 3
0
 public ApplicationViewModel()
 {
     db = new VacancyContext();
     db.Vacancies.Load();
     Vacancies = db.Vacancies.Local.ToBindingList();
 }
Esempio n. 4
0
 public VacancyItemsController(VacancyContext context)
 {
     _context = context;
 }