Esempio n. 1
0
 public List <S> Select <S>(Expression <Func <T, S> > selector)
 {
     using (VETEntities entities = new VETEntities())
     {
         return(entities.Set <T>().Select(selector).ToList());
     }
 }
Esempio n. 2
0
 public int GetCount()
 {
     using (VETEntities entities = new VETEntities())
     {
         return(entities.Set <T>().Count());
     }
 }
Esempio n. 3
0
 public List <T> GetAll()
 {
     using (VETEntities entities = new VETEntities())
     {
         return(entities.Set <T>().ToList());
     }
 }
Esempio n. 4
0
 public void Delete(T entity)
 {
     using (VETEntities entities = new VETEntities())
     {
         entities.Entry(entity).State = EntityState.Deleted;
         entities.SaveChanges();
     }
 }
Esempio n. 5
0
 public void Update(T entity)
 {
     using (VETEntities entities = new VETEntities())
     {
         entities.Entry(entity).State = EntityState.Modified;
         entities.SaveChanges();
     }
 }
Esempio n. 6
0
        public List <Breeds> GetBreeds(int selectedValue)
        {
            using (VETEntities entities = new VETEntities())
            {
                var query = from x in entities.Breeds
                            where x.SpeciesID == selectedValue
                            select x;

                return(query.ToList());
            }
        }
        public List <Prescription> GetRecord(int patientID)
        {
            using (VETEntities entities = new VETEntities())
            {
                var query = from x in entities.Prescription
                            where x.PatientID == patientID
                            select x;

                List <Prescription> prescriptions = query.ToList();

                return(prescriptions);
            }
        }
Esempio n. 8
0
        public List <Patient> Search(string phoneNum, string petName, int?speciesId)
        {
            using (VETEntities entities = new VETEntities())
            {
                entities.Database.Log = x => Debug.WriteLine(x);

                var query = from x in entities.Patient
                            select new
                {
                    patient       = x,
                    CompanionName = x.Companion.Name,
                    EmployeeName  = x.Employee.Name,
                    BreedsName    = x.Breeds.Name,
                    PhoneNumber   = x.Companion.Phone,
                    SpeciesId     = x.Breeds.SpeciesID
                };

                if (string.IsNullOrEmpty(phoneNum) == false)
                {
                    query = query.Where(x => x.patient.Companion.Phone.Contains(phoneNum));
                }

                if (string.IsNullOrEmpty(petName) == false)
                {
                    query = query.Where(x => x.patient.Name.Contains(petName));
                }

                if (speciesId != null)
                {
                    query = query.Where(x => x.SpeciesId == speciesId);
                }

                var list = query.ToList();

                foreach (var item in list)
                {
                    item.patient.CompanionName = item.CompanionName;
                    item.patient.EmployeeName  = item.EmployeeName;
                    item.patient.BreedsName    = item.BreedsName;
                    item.patient.PhoneNumber   = item.PhoneNumber;
                    item.patient.SpeciesID     = item.SpeciesId;
                }

                return(list.ConvertAll(x => x.patient));
            }
        }
Esempio n. 9
0
        public void Insert(T entity)
        {
            using (VETEntities entities = new VETEntities())
            {
                entities.Set <T>().Add(entity);
                //entities.Entry(entity).State = EntityState.Added;

                try
                {
                    entities.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    MessageBox.Show("ValidatoinExceptionTest");
                    throw;
                }
            }
        }
Esempio n. 10
0
        public Patient SearchFromTreatementControl(string petName)
        {
            using (VETEntities entities = new VETEntities())
            {
                var query = from x in entities.Patient
                            select x;

                if (string.IsNullOrEmpty(petName) == false)
                {
                    query = query.Where(x => x.Name.Contains(petName));
                }

                Patient patient = new Patient();

                foreach (var item in query)
                {
                    patient = item;
                }

                return(patient);
            }
        }
Esempio n. 11
0
        public List <Employee> Search(string name, string num)
        {
            using (VETEntities entities = new VETEntities())
            {
                entities.Database.Log = x => Debug.WriteLine(x);

                var query = from x in entities.Employee
                            select x;

                if (string.IsNullOrEmpty(name) == false)
                {
                    query = query.Where(x => x.Name.Contains(name));
                }

                if (string.IsNullOrEmpty(num) == false)
                {
                    query = query.Where(x => x.PhoneNum.Contains(num));
                }

                return(query.ToList());
            }
        }