Exemple #1
0
 /// <summary>
 /// saves an instance of type Dantist in DB
 /// </summary>
 /// <param name="dantist"></param>
 public static void SaveDantist(Dantist dantist)
 {
     using (var ctx = new PatientsContext())
     {
         ctx.Entry(dantist).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemple #2
0
 /// <summary>
 /// adds an instance of type Dantist to DB
 /// </summary>
 /// <param name="dantist"></param>
 public static void AddDantist(Dantist dantist)
 {
     using (var ctx = new PatientsContext())
     {
         ctx.Dantists.Add(dantist);
         ctx.SaveChanges();
     }
 }
Exemple #3
0
 /// <summary>
 /// returns list of instances of type Patient for an instance of type Dantist wiht given id
 /// </summary>
 /// <param name="searchText"></param>
 /// <param name="dantistId"></param>
 /// <returns></returns>
 public static List <Patient> GetAllPatients(string searchText, int dantistId)
 {
     using (var ctx = new PatientsContext())
     {
         Dantist        dantist  = ctx.Dantists.Find(dantistId);
         List <Patient> patients = dantist.Patients.Where(s => s.Name.Contains(searchText) || s.Surname.Contains(searchText) || s.PhoneNumber.Contains(searchText) || s.Address.CityOrTown.Contains(searchText) || string.IsNullOrEmpty(searchText)).OrderByDescending(s => s.LastVisitDate).ToList();
         return(patients);
     }
 }
Exemple #4
0
 /// <summary>
 /// add an instance of type Patient to an instance of type Dantist
 /// with given id and saves that to DB
 /// </summary>
 /// <param name="dantistId"></param>
 /// <param name="patient"></param>
 public static void AddPatient(int dantistId, Patient patient)
 {
     using (var ctx = new PatientsContext())
     {
         Dantist dantist = ctx.Dantists.Find(dantistId);
         dantist.Patients.Add(patient);
         ctx.Entry(dantist).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemple #5
0
 /// <summary>
 /// checks if an instance exists in DB
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="Surname"></param>
 /// <param name="DoB"></param>
 /// <param name="dantistId"></param>
 /// <returns></returns>
 public static Boolean PatientExists(string Name, string Surname, DateTime DoB, int dantistId)
 {
     using (var ctx = new PatientsContext())
     {
         Dantist dantist = ctx.Dantists.Find(dantistId);
         if (dantist.Patients.Where(s => s.Name == Name && s.Surname == Surname && s.DOB == DoB).ToList().Count != 0)
         {
             return(true);
         }
         return(false);
     }
 }
Exemple #6
0
 /// <summary>
 /// removes an instance of type Dantist from DB
 /// </summary>
 /// <param name="id"></param>
 public static void DeleteDantist(int?id, string folderPath)
 {
     using (var ctx = new PatientsContext())
     {
         Dantist dantist = ctx.Dantists.Find(id);
         ctx.Dantists.Remove(dantist);
         ctx.SaveChanges();
     }
     if (Directory.Exists(folderPath))
     {
         Directory.Delete(folderPath, true);
     }
 }
Exemple #7
0
 /// <summary>
 /// returns an instance of type Dantist upon given parameters
 /// </summary>
 /// <param name="id"></param>
 /// <param name="email"></param>
 /// <returns></returns>
 public static Dantist GetDantist(int?id = null, string email = null)
 {
     using (var ctx = new PatientsContext())
     {
         if (id != null)
         {
             Dantist dantist = ctx.Dantists.Find(id);
             return(dantist);
         }
         else
         {
             List <Dantist> dantists = ctx.Dantists.Where(m => m.Email == email).ToList();
             Dantist        dantist  = dantists[0];
             return(dantist);
         }
     }
 }