public void DeleteVacancy(Vacancy vacancy) { foreach (var apply in vacancy.Applies) { Users.FirstOrDefault(u => u.Id == apply.UserId).Applies.Remove(apply); Applies.Remove(apply); } Vacancies.Remove(vacancy); Recruters.FirstOrDefault(r => r == CurrentHR).Vacancies.Remove(vacancy); OnAppliesChanged?.Invoke(); OnVacanciesChanged?.Invoke(); SaveConfig(); }
private void Vacancies_CollectionChanged1(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (Vacancy vacancy in e.NewItems) { if (!Vacancies.Contains(vacancy)) { Vacancies.Add(vacancy); } } break; case NotifyCollectionChangedAction.Remove: foreach (Vacancy vacancy in e.OldItems) { if (Vacancies.Contains(vacancy)) { Vacancies.Remove(vacancy); } } break; case NotifyCollectionChangedAction.Replace: break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Reset: break; default: break; } }
public void Fill_Test_Data(int n) { List <string> pos = new List <string>(); try { using (StreamReader sr = new StreamReader("Position.txt", System.Text.Encoding.Default)) { string line; while ((line = sr.ReadLine()) != null) { pos.Add(line); } } } catch (System.IO.FileNotFoundException) { File.Create("Position.txt"); } List <string> spec = new List <string>(); try { using (StreamReader sr = new StreamReader("Speciality.txt", System.Text.Encoding.Default)) { string line; while ((line = sr.ReadLine()) != null) { spec.Add(line); } } } catch (System.IO.FileNotFoundException) { File.Create("Speciality.txt"); } if (pos.Count != 0 && spec.Count != 0) { //Vacancies if (Vacancies.Count == 0) { Vacancies.Clear(); for (int i = 0; i < n * 2; ++i) { Vacancies.Add(new Vacancy(pos[i % pos.Count], spec[i % spec.Count], 10000 + (i * 15.65))); } } //Job Seekers if (Job_Seekers.Count == 0) { Job_Seekers.Clear(); for (int i = 1; i <= n * 2; ++i) { Job_Seekers.Add(new Job_Seeker($"Name{i % 50}", $"Surname{i % 200}", DateTime.Now - TimeSpan.FromDays(7000) - TimeSpan.FromDays(i * i), "" + Convert.ToChar(i % 120) + $"{i * 8}", "Higher", spec[i % spec.Count], $"{i * 100 + (i + 3) * 10 + i}")); } } //Employees if (Employees.Count == 0) { Employees.Clear(); for (int i = 0; i < n; ++i) { Employees.Add(new Employee(Job_Seekers[i], Vacancies[i])); Job_Seekers.Remove(Job_Seekers[i]); Vacancies.Remove(Vacancies[i]); } } //Orders if (Orders.Count == 0) { Orders.Clear(); for (int i = 0; i < n / 2; ++i) { Orders.Add(new Order(Employees[i])); Orders.Add(new Order(Job_Seekers[i], Vacancies[i])); } } if (Director == null) { //Director //Создадим по 1 виду пользователя с более конкретнымми данными //для авторизации и проверки работоспособности приложения Employees.Add(new Employee(new Job_Seeker("EmployeeName", "EmployeeSurname", DateTime.Now - TimeSpan.FromDays(7000), "ANK1254", "Hight", "Loyer", "Employee"), Vacancies.Last())); Vacancies.Remove(Vacancies.Last()); Employees.Add(new Employee(new Job_Seeker("DirectorName", "DirectorSurname", DateTime.Now - TimeSpan.FromDays(8000), "SDK9054", "Hight", "Loyer", "Director"), Vacancies.Last())); Vacancies.Remove(Vacancies.Last()); Chenge_Director(Employees.Last()); Job_Seekers.Add(new Job_Seeker("JobseekerName", "JobseekerSurname", DateTime.Now - TimeSpan.FromDays(10000), "RTG1569", "Hight", "Pediatric_radiology", "Jobseeker")); } Save(); } }