Exemplo n.º 1
0
        public IEnumerable <Doctor> List()
        {
            var db = new VetDbContext();
            IEnumerable <Doctor> docs = db.Doctors.ToList();

            return(docs);
        }
Exemplo n.º 2
0
        public void Insert(Appointment app)
        {
            var context = new VetDbContext();

            context.Appointments.Add(app);
            context.SaveChanges();
        }
Exemplo n.º 3
0
        public void Insert(Doctor doc)
        {
            var db = new VetDbContext();

            db.Doctors.Add(doc);
            db.SaveChanges();
        }
Exemplo n.º 4
0
        public Patient GetById(int id)
        {
            var context = new VetDbContext();
            var patient = context.Patients.Include(p => p.Owner).ToList();

            return(patient.Find(p => p.Id == id));
        }
Exemplo n.º 5
0
        public void Delete(int id)
        {
            var context = new VetDbContext();

            context.Appointments.Remove(context.Appointments.Find(id));
            context.SaveChanges();
        }
Exemplo n.º 6
0
        public void Insert(Patient patient)
        {
            var context = new VetDbContext();

            context.Patients.Add(patient);
            context.SaveChanges();
        }
Exemplo n.º 7
0
        public IEnumerable <Room> List()
        {
            var context = new VetDbContext();
            var rooms   = context.Rooms.ToList();

            return(rooms);
        }
Exemplo n.º 8
0
        public void Insert(Room room)
        {
            var db = new VetDbContext();

            db.Rooms.Add(room);
            db.SaveChanges();
        }
Exemplo n.º 9
0
        public void Insert(Client cli)
        {
            var context = new VetDbContext();

            context.Clients.Add(cli);
            context.SaveChanges();
        }
Exemplo n.º 10
0
        public void Delete(int id)
        {
            var db  = new VetDbContext();
            var doc = db.Doctors.Find(id);

            db.Doctors.Remove(doc);
            db.SaveChanges();
        }
Exemplo n.º 11
0
        public void Delete(int id)
        {
            var context = new VetDbContext();
            var patient = context.Patients.Find(id);

            context.Patients.Remove(patient);
            context.SaveChanges();
        }
Exemplo n.º 12
0
        public void Delete(int id)
        {
            var  db   = new VetDbContext();
            Room room = db.Rooms.Find(id);

            db.Rooms.Remove(room);
            db.SaveChanges();
        }
Exemplo n.º 13
0
        public void Update(Room entity)
        {
            var  context  = new VetDbContext();
            Room editRoom = context.Rooms.Find(entity.Id);

            if (entity != null)
            {
                editRoom.Location = entity.Location;
                editRoom.Name     = entity.Name;
            }
            context.SaveChanges();
        }
Exemplo n.º 14
0
        public void Update(Client updated)
        {
            var context = new VetDbContext();
            var client  = context.Clients.Find(updated.Id);

            if (client != null)
            {
                client.FullName    = updated.FullName;
                client.Email       = updated.Email;
                client.PhoneNumber = updated.PhoneNumber;
            }
            context.SaveChanges();
        }
Exemplo n.º 15
0
        public string ValidationCheck(Appointment app)
        {
            var context      = new VetDbContext();
            var appointments = context.Appointments.Include(p => p.Doctor)
                               .Include(p => p.Room)
                               .Include(p => p.Patient)
                               .Where(i => i.RoomId == app.RoomId)
                               .Where(i => i.StartDate == app.StartDate)
                               .Where(i => i.Id != app.Id);
            string error = null;

            if (app.StartDate == app.EndDate)
            {
                error = "Start date can not be equal to End date.";
                return(error);
            }
            if (app.StartDate > app.EndDate)
            {
                error = "Start date can not be grater than End date.";
                return(error);
            }

            var hours = app.EndDate - app.StartDate;

            if (hours.Hours > 6 || hours.Days >= 1)
            {
                error = "The appointments duration can not be grather than 6 hours.";
                return(error);
            }

            if (app != null && appointments.Count() > 0)
            {
                if (appointments.Where(i => i.DoctorId == app.DoctorId).Count() > 0)
                {
                    error = "The doctor already has an appointment at the same time";
                    return(error);
                }
                if (appointments.Where(i => i.RoomId == app.RoomId).Count() > 0)
                {
                    error = "The room is taken for the give time.";
                    return(error);
                }
                if (appointments.Where(i => i.PatientId == app.PatientId).Count() > 0)
                {
                    error = "The patient already has an appointment at the same time";
                    return(error);
                }
            }

            return(error);
        }
Exemplo n.º 16
0
        public void Update(Patient updated)
        {
            var context = new VetDbContext();
            var patient = context.Patients.Find(updated.Id);

            if (!(patient is null))
            {
                patient.Name     = updated.Name;
                patient.Gender   = updated.Gender;
                patient.Owner    = updated.Owner;
                patient.ClientId = updated.ClientId;
                patient.ImgPath  = updated.ImgPath;
            }
            context.SaveChanges();
        }
Exemplo n.º 17
0
        public void Update(Doctor update)
        {
            var    db  = new VetDbContext();
            Doctor doc = db.Doctors.Find(update.Id);

            if (doc != null)
            {
                doc.Name        = update.Name;
                doc.LastName    = update.LastName;
                doc.Email       = update.Email;
                doc.Address     = update.Address;
                doc.PhoneNumber = update.PhoneNumber;
            }
            db.SaveChanges();
        }
Exemplo n.º 18
0
        public void Update(Appointment updated)
        {
            var context = new VetDbContext();
            var app     = context.Appointments.Find(updated.Id);

            if (app != null)
            {
                app.PatientId   = updated.PatientId;
                app.RoomId      = updated.RoomId;
                app.DoctorId    = updated.DoctorId;
                app.StartDate   = updated.StartDate;
                app.EndDate     = updated.EndDate;
                app.Description = updated.Description;
            }
            context.SaveChanges();
        }
Exemplo n.º 19
0
        public Doctor GetById(int id)
        {
            var db = new VetDbContext();

            return(db.Doctors.Find(id));
        }
Exemplo n.º 20
0
        public IEnumerable <Patient> List()
        {
            var patients = new VetDbContext().Patients.Include(p => p.Owner);

            return(patients.ToList());
        }
Exemplo n.º 21
0
        public IEnumerable <Appointment> List()
        {
            var appointments = new VetDbContext().Appointments.Include(p => p.Doctor).Include(p => p.Room).Include(p => p.Patient);

            return(appointments.ToList());
        }
Exemplo n.º 22
0
        public Room GetById(int id)
        {
            var db = new VetDbContext();

            return(db.Rooms.Find(id));
        }
Exemplo n.º 23
0
        public IEnumerable <Client> List()
        {
            IEnumerable <Client> clients = new VetDbContext().Clients.ToList();

            return(clients);
        }