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

            return(docs);
        }
        public void Insert(Appointment app)
        {
            var context = new VetDbContext();

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

            db.Doctors.Add(doc);
            db.SaveChanges();
        }
        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));
        }
        public void Delete(int id)
        {
            var context = new VetDbContext();

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

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

            return(rooms);
        }
Example #8
0
        public void Insert(Room room)
        {
            var db = new VetDbContext();

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

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

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

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

            db.Rooms.Remove(room);
            db.SaveChanges();
        }
Example #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();
        }
Example #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();
        }
        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);
        }
Example #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();
        }
Example #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();
        }
        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();
        }
Example #19
0
        public Doctor GetById(int id)
        {
            var db = new VetDbContext();

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

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

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

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

            return(clients);
        }