Esempio n. 1
0
        public void AddToClinic(Service service, Clinic.BO.Clinic clinic)
        {
            var existingService = Get(service.Name);

            if (existingService.Id == null)
            {
                Create(service);
            }
            else
            {
                service = existingService;
            }

            string sql;
            int    id = GetNextVal(Sequences.ServiceClinic);

            sql = string.Format(@"
                  INSERT INTO SERVICE_CLINIC
                  (SERVICE_CLINIC_ID, CLINIC_ID, SERVICE_ID)
                  VALUES 
                  ({0},{1},{2})
                  ",
                                id,
                                clinic.Id,
                                service.Id);

            ExecuteQuery(sql);
        }
Esempio n. 2
0
        public void DeleteFromClinic(Service service, Clinic.BO.Clinic clinic)
        {
            string sql = string.Format(@"
                              DELETE FROM SERVICE_CLINIC
                              WHERE SERVICE_ID = {0} 
                                AND CLINIC_ID = {1}
                              ",
                                       service.Id,
                                       clinic.Id);

            ExecuteQuery(sql);
        }
Esempio n. 3
0
        public Clinic.BO.Clinic Get(int id)
        {
            var obj = new Clinic.BO.Clinic();

            string sql = string.Format(@"
                         SELECT * FROM CLINIC 
                         WHERE CLINIC_ID = {0}
                         ", id);

            ExecuteReader(sql, obj, Populate);

            return(obj);
        }
Esempio n. 4
0
        public void Create(Clinic.BO.Clinic clinic)
        {
            int id = GetNextVal(Sequences.Clinic);

            string sql = string.Format(@"
                         INSERT INTO CLINIC
                         (CLINIC_ID, ENTITY_ID)
                         VALUES 
                         ({0},{1})
                         ",
                                       id,
                                       clinic.EntityId);

            ExecuteQuery(sql);

            clinic.Id = id;
        }
Esempio n. 5
0
        public void Update(Clinic.BO.Clinic clinic)
        {
            if (clinic.EntityId == null)
            {
                BusinessLayer.EntityBL.Create(clinic);
            }
            else
            {
                BusinessLayer.EntityBL.Update(clinic);
            }

            if (clinic.Id.HasValue)
            {
                DataLayer.ClinicDL.Update(clinic);
            }
            else
            {
                DataLayer.ClinicDL.Create(clinic);
            }

            var existingClinic = BusinessLayer.ClinicBL.Get(clinic.Id.Value);

            var newProviders     = clinic.Providers.Where(x => !existingClinic.Providers.Any(existing => existing.Id == x.Id)).ToList();
            var removedProviders = existingClinic.Providers.Where(existing => !clinic.Providers.Any(cur => cur.Id.Value == existing.Id.Value)).ToList();

            var newServices     = clinic.Services.Where(x => !x.Id.HasValue).ToList();
            var updatedServices = clinic.Services.Where(x => x.Id.HasValue).ToList();
            var removedServices = existingClinic.Services.Where(existing => !updatedServices.Any(cur => cur.Id.Value == existing.Id.Value)).ToList();

            var newRooms     = clinic.Rooms.Where(x => !x.Id.HasValue).ToList();
            var updatedRooms = clinic.Rooms.Where(x => x.Id.HasValue).ToList();
            var removedRooms = existingClinic.Rooms.Where(existing => !updatedRooms.Any(cur => cur.Id.Value == existing.Id.Value)).ToList();

            newProviders.ForEach(x => DataLayer.ProviderDL.Create(clinic.Id.Value, x));
            removedProviders.ForEach(x => DataLayer.ProviderDL.Delete(clinic.Id.Value, x));

            newServices.ForEach(x => DataLayer.ServiceDL.AddToClinic(x, clinic));
            updatedServices.ForEach(x => DataLayer.ServiceDL.Update(x));
            removedServices.ForEach(x => DataLayer.ServiceDL.DeleteFromClinic(x, clinic));

            newRooms.ForEach(x => DataLayer.RoomDL.Create(clinic.Id.Value, x));
            updatedRooms.ForEach(x => DataLayer.RoomDL.Update(x));
            removedRooms.ForEach(x => DataLayer.RoomDL.Delete(x));
        }
Esempio n. 6
0
 public void Update(Clinic.BO.Clinic clinic)
 {
     // DO Nothing
     // Name (on entity) and all others should be update in their respective layers
 }