Exemplo n.º 1
0
        public Boolean isExist(Object obj)
        {
            bool exist = false;

            if (obj.GetType() == typeof(Area))
            {
                areaSessionData = new AreaSessionData();
                Area area = areaSessionData.getAreaByName((Area)obj);
                exist = (area != null) ? true : false;
            }
            else if (obj.GetType() == typeof(Cooperative))
            {
                cooperativeSessionData = new CooperativeSessionData();
                Cooperative coop = cooperativeSessionData.getCooperativeByName((Cooperative)obj);
                exist = (coop != null) ? true : false;
            }
            else if (obj.GetType() == typeof(Plant))
            {
                plantSessionData = new PlantDataSession();
                Plant plant = plantSessionData.getPlantByNameAndCooperative((Plant)obj);
                exist = (plant != null) ? true : false;
            }
            else if (obj.GetType() == typeof(Regions))
            {
                regionSessionData = new RegionSessionData();
                Regions region = regionSessionData.getRegionByName((Regions)obj);
                exist = (region != null) ? true : false;
            }
            else if (obj.GetType() == typeof(DataType))
            {
                exist = ((DataType)search(obj) != null) ? true : false;
            }

            return(exist);
        }
Exemplo n.º 2
0
        public Object search(Object obj)
        {
            object resultObj = null;

            if (obj.GetType() == typeof(Area))
            {
                areaSessionData = new AreaSessionData();
                Area area = areaSessionData.getAreaByName((Area)obj);
                resultObj = area;
            }
            else if (obj.GetType() == typeof(Cooperative))
            {
                Cooperative cooperative = (Cooperative)obj;

                cooperativeSessionData = new CooperativeSessionData();
                Cooperative coop = cooperativeSessionData.getCooperativeByNameAndRegionId(cooperative, cooperative.regionId);
                resultObj = coop;
            }
            else if (obj.GetType() == typeof(Plant))
            {
                Plant planta = (Plant)obj;

                plantSessionData = new PlantDataSession();
                Plant plant = plantSessionData.getPlantByNameAndCooperative(planta); // plantSessionData.getPlantByName((Plant)obj);
                resultObj = plant;
            }
            else if (obj.GetType() == typeof(Regions))
            {
                regionSessionData = new RegionSessionData();
                Regions region = regionSessionData.getRegionByName((Regions)obj);
                resultObj = region;
            }
            else if (obj.GetType() == typeof(DataType))
            {
                dataTypeSessionData = new DataTypeSessionData();
                DataType dataType = dataTypeSessionData.getDataTypeByName((DataType)obj);
                resultObj = dataType;
            }
            return(resultObj);
        }