public WorkingHour GetById(long id)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         return(dbContext.WorkingHours.SingleOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 2
0
 public IList <Doctor> GetDoctors(Procedure procedure)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         return(dbContext.Doctors.Where(x => x.Procedures.Any(y => y.Id == procedure.Id)).ToList());
     }
 }
Ejemplo n.º 3
0
 public Procedure GetById(long id)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         return(dbContext.Procedures.SingleOrDefault(x => x.Id == id));
     }
 }
 public void Insert(WorkingHour workingHour)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         dbContext.WorkingHours.Add(workingHour);
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 public void Insert(Doctor doctor)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         dbContext.Doctors.Add(doctor);
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void Insert(Procedure procedure)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         dbContext.Procedures.Add(procedure);
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public User GetByUserName(string name)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         var dbUser = dbContext.Users.SingleOrDefault(x => x.UserName == name);
         return(dbUser);
     }
 }
Ejemplo n.º 8
0
 public bool IsValid(string userName, string password)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         var dbUser = dbContext.Users.SingleOrDefault(x => x.UserName == userName);
         return(dbUser != null && dbUser.Password == password);
     }
 }
Ejemplo n.º 9
0
 public IList <Procedure> GetAll()
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         var d = dbContext.Procedures;
         var e = d.ToList();
         return(e);
         //dbContext.Procedures.ToList();
     }
 }
Ejemplo n.º 10
0
 public IList <Appointment> GetAll()
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         return
             (dbContext.Appointments.Include(x => x.Doctor)
              .Include(x => x.Time)
              .Include(x => x.Procedure)
              .ToList());
     }
 }
Ejemplo n.º 11
0
 public void Insert(Appointment appointment)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         dbContext.Entry(appointment.Doctor).State    = EntityState.Unchanged;
         dbContext.Entry(appointment.Procedure).State = EntityState.Unchanged;
         dbContext.Entry(appointment.Time).State      = EntityState.Unchanged;
         dbContext.Appointments.Add(appointment);
         dbContext.SaveChanges();
     }
 }
 public IList <WorkingHour> GetFreeWorkingHours(long doctorId, DateTimeOffset date)
 {
     using (var dbContext = new SoftTehnicaDbContext())
     {
         var timeIds = dbContext.Appointments.Where(x => x.Doctor.Id == doctorId)
                       .Where(x => x.Date == date).Select(x => x.Time);
         var t =
             dbContext.WorkingHours.Where(y => y.Doctors.Any(x => x.Id == doctorId))
             .Where(x => !timeIds.Any(y => y.Id == x.Id))
             .ToList();
         return(t);
     }
 }