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"); } WizardSoilHorizonViewModel vmReturn = new WizardSoilHorizonViewModel(); vmReturn.Farm = this.LoadFarms(); return(View("~/Views/Wizard/SoilHorizon/Wizard.cshtml", vmReturn)); }