Ejemplo n.º 1
0
 public ActionResult Create([Bind(Include = "StageId,Name,ShortName, Description, Order")] Stage stage)
 {
     if (ModelState.IsValid)
     {
         db.Stages.Add(stage);
         db.SaveChanges();
     }
     return(Redirect("/Stages"));
 }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "WeatherStationId,Name,Model,DateOfInstallation,DateOfService,UpdateTime,WirelessTransmission,GiveET,WeatherDataType, Enabled, Latitude, Longitude, FarmIdSelected")] WeatherStationViewModel wsm)
        {
            var a = wsm.FarmId;

            if (ModelState.IsValid)
            {
                WeatherStation ws = new WeatherStation();

                long lPositionId = GetPositionId(wsm.Latitude, wsm.Longitude);
                //Not exist position to farm
                if (lPositionId == 0)
                {
                    Position lPosition = new Position();
                    lPosition.Latitude  = wsm.Latitude;
                    lPosition.Longitude = wsm.Longitude;
                    lPosition.Name      = wsm.Name + " - Estación meteorológica";
                    ws.Position         = lPosition;
                }
                else
                {
                    ws.PositionId = lPositionId;
                }
                ws.DateOfInstallation = wsm.DateOfInstallation;
                ws.DateOfService      = wsm.DateOfService;
                ws.Enabled            = wsm.Enabled;
                ws.GiveET             = wsm.GiveET;
                ws.Model                = wsm.Model;
                ws.Name                 = wsm.Name;
                ws.StationType          = wsm.StationType;
                ws.UpdateTime           = wsm.UpdateTime;
                ws.WeatherDataType      = wsm.WeatherDataType;
                ws.WebAddress           = wsm.WebAddress;
                ws.WirelessTransmission = wsm.WirelessTransmission;

                db.WeatherStations.Add(ws);
                db.SaveChanges();

                WeatherStationConfiguration wsc = new WeatherStationConfiguration();
                long lastWeatherStationId       = wsc.GetMaxWeatherStationId();

                //Save Relation whit Farm
                if (wsm.FarmIdSelected != null)
                {
                    string[] farmIds = wsm.FarmIdSelected.Split('|');
                    foreach (var farmId in farmIds)
                    {
                        Farm lFarm = db.Farms.Find(int.Parse(farmId));
                        lFarm.WeatherStationId = lastWeatherStationId;
                        db.Entry(lFarm).State  = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            return(Redirect("/WeatherStations"));
            // return View("~/Views/Weather/WeatherStations/Index.cshtml", db.WeatherStations.ToList());
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Name, ShortName, Description, Latitude, Longitude, TestDate, DepthLimit, FarmId, HorizonsHidden")] WizardSoilHorizonViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Soil soilMapped      = new Soil();
                long lsoilPositionId = GetPositionId(vm.Latitude, vm.Longitude);

                Position positionAux = new Position();
                //Not exist position to Soil
                if (lsoilPositionId == 0)
                {
                    positionAux.Latitude  = vm.Latitude;
                    positionAux.Longitude = vm.Longitude;
                    positionAux.Name      = vm.Name + " - Suelo";
                    soilMapped.Position   = positionAux;
                }
                else
                {
                    soilMapped.PositionId = lsoilPositionId;
                }

                // working whit Horizont
                dynamic items = JsonConvert.DeserializeObject(vm.HorizonsHidden);
                foreach (var item in items.items)
                {
                    //Horizon horizon = new Horizon();
                    string lhorizonName       = item.horizonName;
                    int    lorder             = item.order;
                    string lhorizonLayer      = item.horizonLayer;
                    double lhorizonLayerDepth = item.horizonLayerDepth;
                    double lsand             = item.sand;
                    double llimo             = item.limo;
                    double lclay             = item.clay;
                    double lorganicMatter    = item.organicMatter;
                    double lnitrogenAnalysis = item.nitrogenAnalysis;
                    double lbulkDensitySoil  = item.bulkDensitySoil;


                    soilMapped.AddHorizon(lhorizonName, lorder, lhorizonLayer, lhorizonLayerDepth, lsand, llimo, lclay, lorganicMatter, lnitrogenAnalysis, lbulkDensitySoil);
                }
                soilMapped.ShortName   = vm.ShortName;
                soilMapped.Name        = vm.Name;
                soilMapped.Description = vm.Description;
                soilMapped.TestDate    = vm.TestDate;
                soilMapped.DepthLimit  = vm.DepthLimit;
                soilMapped.FarmId      = vm.FarmId;
                db.Soils.Add(soilMapped);
                db.SaveChanges();

                ////return RedirectToAction("Index");
            }
            return(Redirect("/Soils"));

            //var lSoilList = db.Soils.Include(b => b.Farm);
            //return View("~/Views/Agriculture/Soils/Index.cshtml", lSoilList.ToList());
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "RoleId,Name,SiteId,MenuId")] Role role)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
        public ActionResult Create([Bind(Include = "WeatherStationId,Name,Model,DateOfInstallation,DateOfService,UpdateTime,WirelessTransmission,GiveET,WeatherDataType")] WeatherStation weatherStation)
        {
            if (ModelState.IsValid)
            {
                db.WeatherStations.Add(weatherStation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(weatherStation));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "BombId,Name,SerialNumber,ServiceDate,PurchaseDate")] Bomb bomb)
        {
            if (ModelState.IsValid)
            {
                db.Bombs.Add(bomb);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bomb));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "EffectiveRainId,Month,MinRain,MaxRain,Percentage")] EffectiveRain effectiveRain)
        {
            if (ModelState.IsValid)
            {
                db.EffectiveRains.Add(effectiveRain);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(effectiveRain));
        }
        public ActionResult Create([Bind(Include = "CountryId,Name,LanguageId,CapitalId")] Country country)
        {
            if (ModelState.IsValid)
            {
                db.Countries.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "WaterInputId,Type,Input,Date,ExtraInput,ExtraDate")] Models.Water.Irrigation irrigation)
        {
            if (ModelState.IsValid)
            {
                db.Irrigations.Add(irrigation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(irrigation));
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "PositionId,Name,Latitude,Longitude")] Position position)
        {
            if (ModelState.IsValid)
            {
                db.Positions.Add(position);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(position));
        }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "IrrigationUnitId,Name,IrrigationType,IrrigationEfficiency,Surface,Radius")] Pivot pivot)
        {
            if (ModelState.IsValid)
            {
                db.Pivots.Add(pivot);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pivot));
        }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "TitleId,CropIrrigationWeatherId")] Title title)
        {
            if (ModelState.IsValid)
            {
                db.Titles.Add(title);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(title));
        }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "SiteMapId,Name")] Models.Security.SiteMap siteMap)
        {
            if (ModelState.IsValid)
            {
                db.SiteMaps.Add(siteMap);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(siteMap));
        }
Ejemplo n.º 14
0
        public ActionResult Create([Bind(Include = "MenuId,Name")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                db.Menus.Add(menu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(menu));
        }
Ejemplo n.º 15
0
        public ActionResult Create([Bind(Include = "SpecieCycleId,Name,Duration")] SpecieCycle specieCycle)
        {
            if (ModelState.IsValid)
            {
                db.SpecieCycles.Add(specieCycle);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(specieCycle));
        }
Ejemplo n.º 16
0
        public ActionResult Create([Bind(Include = "SoilId,Name,Description,TestDate,DepthLimit")] Soil soil)
        {
            if (ModelState.IsValid)
            {
                db.Soils.Add(soil);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(soil));
        }
Ejemplo n.º 17
0
        public ActionResult Create([Bind(Include = "FarmId,Name,Address,Phone,Has")] Farm farm)
        {
            if (ModelState.IsValid)
            {
                db.Farms.Add(farm);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(farm));
        }
Ejemplo n.º 18
0
        public ActionResult Create([Bind(Include = "DailyRecordId,DailyRecordDateTime,DaysAfterSowing,DaysAfterSowingModified,GrowingDegreeDays,GrowingDegreeDaysAccumulated,GrowingDegreeDaysModified,LastWaterInputDate,LastBigWaterInputDate,LastPartialWaterInputDate,LastPartialWaterInput,HydricBalance,SoilHydricVolume,TotalEvapotranspirationCropFromLastWaterInput,CropCoefficient,Observations,TotalEvapotranspirationCrop,TotalEffectiveRain,TotalRealRain,TotalIrrigation,TotalIrrigationInHydricBalance,TotalExtraIrrigation,TotalExtraIrrigationInHydricBalance,CropIrrgationWeatherId")] DailyRecord dailyRecord)
        {
            if (ModelState.IsValid)
            {
                db.DailyRecords.Add(dailyRecord);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dailyRecord));
        }
        public ActionResult Create([Bind(Include = "PhenologicalStageId,MinDegree,MaxDegree,RootDepth,HydricBalanceDepth")] PhenologicalStage phenologicalStage)
        {
            if (ModelState.IsValid)
            {
                db.PhenologicalStages.Add(phenologicalStage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(phenologicalStage));
        }
Ejemplo n.º 20
0
        public ActionResult Create([Bind(Include = "IrrigationUnitId,Name,IrrigationType,IrrigationEfficiency,Surface,Width,Length")] Sprinkler sprinkler)
        {
            if (ModelState.IsValid)
            {
                db.Sprinklers.Add(sprinkler);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sprinkler));
        }
        public ActionResult Create([Bind(Include = "CropIrrigationWeatherId,SowingDate,HarvestDate,CropDate,HydricBalance,SoilHydricVolume,TotalEvapotranspirationCropFromLastWaterInput,DaysAfterSowing,DaysAfterSowingModified,GrowingDegreeDaysAccumulated,GrowingDegreeDaysModified,PredeterminatedIrrigationQuantity,LastWaterInputDate,LastBigWaterInputDate,LastPartialWaterInputDate,LastPartialWaterInput,UsingMainWeatherStation,TotalEvapotranspirationCrop,TotalEffectiveRain,TotalRealRain,TotalIrrigation,TotalIrrigationInHydricBalance,TotalExtraIrrigation,TotalExtraIrrigationInHydricBalance,OutPut")] CropIrrigationWeather cropIrrigationWeather)
        {
            if (ModelState.IsValid)
            {
                db.CropIrrigationWeathers.Add(cropIrrigationWeather);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cropIrrigationWeather));
        }
Ejemplo n.º 22
0
        public ActionResult Create([Bind(Include = "CropCoefficientId")] CropCoefficient cropCoefficient)
        {
            if (ModelState.IsValid)
            {
                db.CropCoefficients.Add(cropCoefficient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cropCoefficient));
        }
        public ActionResult Create([Bind(Include = "CropInformationByDateId,SowingDate,CurrentDate,DaysAfterSowing,AccumulatedGrowingDegreeDays,CropCoefficientValue,RootDepth")] CropInformationByDate cropInformationByDate)
        {
            if (ModelState.IsValid)
            {
                db.CropInformationByDates.Add(cropInformationByDate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cropInformationByDate));
        }
Ejemplo n.º 24
0
        public ActionResult Create([Bind(Include = "SiteItemId,Name")] SiteItem siteItem)
        {
            if (ModelState.IsValid)
            {
                db.SiteItems.Add(siteItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(siteItem));
        }
Ejemplo n.º 25
0
        public ActionResult Create([Bind(Include = "StageId,Name,Description")] Stage stage)
        {
            if (ModelState.IsValid)
            {
                db.Stages.Add(stage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stage));
        }
Ejemplo n.º 26
0
        public ActionResult Create([Bind(Include = "AccessId,Name")] Access access)
        {
            if (ModelState.IsValid)
            {
                db.Accesses.Add(access);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(access));
        }
Ejemplo n.º 27
0
        public ActionResult Create([Bind(Include = "Id,Name,DateOfReference,WebStatus,Description")] Status status)
        {
            if (ModelState.IsValid)
            {
                db.Status.Add(status);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(status));
        }
Ejemplo n.º 28
0
        public ActionResult Create([Bind(Include = "LanguageId,Name")] Models.Language.Language language)
        {
            if (ModelState.IsValid)
            {
                db.Languages.Add(language);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(language));
        }
        public ActionResult Create([Bind(Include = "HorizonId,Name,Order,HorizonLayer,HorizonLayerDepth,Sand,Limo,Clay,OrganicMatter,NitrogenAnalysis,BulkDensitySoil")] Horizon horizon)
        {
            if (ModelState.IsValid)
            {
                db.Horizons.Add(horizon);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(horizon));
        }
        public ActionResult Create([Bind(Include = "SpecieId,Name,SpecieCycleId,BaseTemperature,StressTemperature")] Specie specie)
        {
            if (ModelState.IsValid)
            {
                db.Species.Add(specie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SpecieCycleId = new SelectList(db.SpecieCycles, "SpecieCycleId", "Name", specie.SpecieCycleId);
            return(View(specie));
        }