Example #1
0
        public List <Crop> predictCropsToGrow(int i_SiteID)
        {
            List <Crop> allAllowedCrops = new List <Crop>();

            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                CropRepository            cropRepo          = new CropRepository(context);
                List <Crop>               allCrops          = cropRepo.GetNegevEntityCollection() as List <Crop>;
                List <CropYearPair>       cropYearsPairs    = GetCropsBySiteId(i_SiteID);
                CropsConstrainsRepository cropConstrainRepo = new CropsConstrainsRepository(context);

                foreach (Crop crop in allCrops)
                {
                    bool allowGrow = true;

                    foreach (CropYearPair cyp in cropYearsPairs)
                    {
                        int allowedYears = GetYears(crop.ID, cyp._Crop.ID);
                        if (!determineIfCropAllowed(allowedYears, cyp.Year))
                        {
                            allowGrow = false;
                            break;
                        }
                    }

                    if (allowGrow)
                    {
                        allAllowedCrops.Add(crop);
                    }
                }
            }

            return(allAllowedCrops);
        }
Example #2
0
 private void initializeRepositories(DbContext i_Context)
 {
     m_CoordinateReository  = new CoordinateRepository(i_Context);
     m_CropRepository       = new CropRepository(i_Context);
     m_LayerRepository      = new LayerRepository(i_Context);
     m_SiteRepository       = new SiteRepository(i_Context);
     m_siteByYearRepository = new SiteByYearRepository(i_Context);
 }
Example #3
0
        private void addCrop(string name)
        {
            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                CropRepository            crops         = new CropRepository(context);
                List <Crop>               cropsDataBase = crops.GetNegevEntityCollection() as List <Crop>;
                CropsConstrainsRepository ccrs          = new CropsConstrainsRepository(context);

                Crop c = new Crop();

                c.Name        = name;
                c.Quantity    = 0;
                c.SiteByYears = null;
                c.Description = "";
                crops.AddRow(c);
                crops.Save();
            }
        }
Example #4
0
        private bool isCropExist(string name)
        {
            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                CropRepository cropsRepo     = new CropRepository(context);
                List <Crop>    cropsDataBase = cropsRepo.GetNegevEntityCollection() as List <Crop>;
                bool           answer        = false;

                foreach (Crop crop in cropsDataBase)
                {
                    if (crop.Name.Equals(name))
                    {
                        answer = true;
                        break;
                    }
                }

                return(answer);
            }
        }