Esempio n. 1
0
 public async Task <List <Appointment> > GetAppointmentsByPatient(int patientId)
 {
     using (var context = new ClinicalTemplateContext())
     {
         return(context.Appointments.Where(x => x.PatientId == patientId).ToList());
     }
 }
Esempio n. 2
0
 public async Task <List <Patient> > GetPatients()
 {
     using (var context = new ClinicalTemplateContext())
     {
         return(await context.Patients.ToListAsync());
     }
 }
Esempio n. 3
0
        public async Task <Appointment> DeleteAppointment(int appointmentId)
        {
            using (var context = new ClinicalTemplateContext())
            {
                //Appointment appointment = new Appointment() { Id = appointmentId };
                var appointment = context.Appointments.Where(x => x.Id == appointmentId).FirstOrDefault();
                context.Appointments.Attach(appointment);
                var appointmentTime = new DateTime(appointment.Date.Year,
                                                   appointment.Date.Month,
                                                   appointment.Date.Day,
                                                   appointment.Hour.Hours,
                                                   appointment.Hour.Minutes,
                                                   appointment.Hour.Seconds);
                var nextDay = DateTime.Now.AddDays(1);
                var diff    = (nextDay - appointmentTime).TotalHours;
                if (diff < 24)
                {
                    return(null);
                }

                context.Entry(appointment).State = EntityState.Deleted;
                context.SaveChanges();
                return(appointment);
            }
        }
Esempio n. 4
0
 public async Task <bool> UpdatePatient(Patient patient)
 {
     using (var context = new ClinicalTemplateContext())
     {
         context.Patients.Attach(patient);
         context.Entry(patient).State = EntityState.Modified;
         context.SaveChanges();
     }
     return(true);
 }
Esempio n. 5
0
 public async Task <bool> AddPatient(NewPatient newPatient)
 {
     using (var context = new ClinicalTemplateContext())
     {
         var patient = new Patient()
         {
             Name = newPatient.Name, LastName = newPatient.LastName
         };
         context.Patients.Add(patient);
         context.SaveChanges();
     }
     return(true);
 }
Esempio n. 6
0
 public async Task <Appointment> AddAppointment(NewAppointment newAppointment)
 {
     using (var context = new ClinicalTemplateContext())
     {
         var appointment = new Appointment()
         {
             Type = newAppointment.Type, PatientId = newAppointment.PatientId, Date = newAppointment.Date, Hour = newAppointment.Hour
         };
         context.Appointments.Add(appointment);
         context.SaveChanges();
         return(appointment);
     }
 }
Esempio n. 7
0
 public async Task <bool> DeletePatient(int patientId)
 {
     using (var context = new ClinicalTemplateContext())
     {
         Patient patient = new Patient()
         {
             Id = patientId
         };
         context.Patients.Attach(patient);
         context.Entry(patient).State = EntityState.Deleted;
         context.SaveChanges();
     }
     return(true);
 }