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 ActionResult EditSite(string siteCode = "1007", int typeId = 0, string name = "", string lat = "", string lon = "") { string result = ""; try { Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient(); Site theSite = theHydro.GetSite(siteCode, typeId); if (name != "") { theSite.Name = name; } else { throw new Exception("Пустое поле Наименование поста"); } if (lat != "") { theSite.Lat = Convert.ToDecimal(lat); } else { throw new Exception("Пустое поле Lat поста"); } if (lon != "") { theSite.Lon = Convert.ToDecimal(lon); } else { throw new Exception("Пустое поле Lon поста"); } theHydro.SaveSiteWithRelation(theSite, null); result = "Ok:" + siteCode; } catch (Exception ex) { result = "Error:" + ex.Message; } return(Content(result)); }