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

            return(docs);
        }
예제 #2
0
        public void Insert(Appointment app)
        {
            var context = new VetDbContext();

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

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

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

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

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

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

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

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

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

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

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

            return(patients.ToList());
        }
예제 #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());
        }
예제 #22
0
        public Room GetById(int id)
        {
            var db = new VetDbContext();

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

            return(clients);
        }