public ActionResult Change(int SiteCode, int SiteType, int WaterObject, bool isChecked) { Hydro.Site theSite = null; try { Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient(); theSite = theHydro.GetSite(SiteCode.ToString(), SiteType); if (isChecked) { Hydro.WaterObject theWO = null; foreach (var item in theHydro.GetWaterObjects(false)) { if (item.Id == WaterObject) { theWO = item; break; } } theHydro.SaveSiteWithRelation(theSite, theWO); } else { Hydro.WaterObject wo = new Hydro.WaterObject(); wo.Id = -1; theHydro.SaveSiteWithRelation(theSite, wo); } } catch (Exception ex) { return(Content(ex.Message)); } return(Content("Станция " + theSite.Name + " успешно обновлена")); }
public Site(Hydro.Site site) { this.TypeId = site.Type.Id; this.TypeName = site.Type.Name; this.TypeNameShort = site.Type.ShortName; this.Border = site.Border; this.Comment = site.Comment; this.Id = site.Id; if (site.Lat != null) { this.Lat = (decimal)site.Lat; } else { this.Lat = -1; } if (site.Lon != null) { this.Lon = (decimal)site.Lon; } else { this.Lon = -1; } if (site.LatLonDatumId != null) { this.LatLongDatumID = (int)site.LatLonDatumId; } else { this.LatLongDatumID = -1; } if (site.Height != null) { this.Height = (float)site.Height; this.Elevation_m = (float)site.Height; } else { this.Height = -1; this.Elevation_m = -1; } if (site.LocalProjectionId != null) { this.LocalProjectionID = (int)site.LocalProjectionId; } else { this.LocalProjectionID = -1; } if (site.RegionId != null) { this.RegionId = (int)site.RegionId; } else { this.RegionId = -1; } this.isComplex = site.IsComplex; this.Name = site.Name; this.SiteCode = site.SiteCode; this.SiteId = site.SiteId; this.UtcOffset = site.UtcOffset; this.Id = site.Id; }