-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListDoctorRepo.cs
38 lines (32 loc) · 975 Bytes
/
ListDoctorRepo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace Exam1_2;
public class ListDoctorRepo : IDoctorRepo
{
private List<Doctor> _doctors = new List<Doctor>();
public void Add(Doctor doctor)
{
doctor.Id = _doctors.Count + 1;
_doctors.Add(doctor);
}
public void Delete(int id)
{
_doctors.RemoveAll(d => d.Id == id);
}
public void Update(Doctor doctor)
{
var existingDoctor = _doctors.FirstOrDefault(d => d.Id == doctor.Id);
if (existingDoctor != null)
{
existingDoctor.Name = doctor.Name;
existingDoctor.Specialization = doctor.Specialization;
existingDoctor.ContractType = doctor.ContractType;
}
}
public IEnumerable<Doctor> GetAll()
{
return _doctors;
}
public IEnumerable<Doctor> GetBySpecialization(Specialization specialization)
{
return _doctors.Where(d => d.Specialization == specialization);
}
}