// Check public string MapInfoPointModelOK(MapInfoPointModel mapInfoPointModel) { string retStr = FieldCheckNotZeroInt(mapInfoPointModel.MapInfoID, ServiceRes.MapInfoID); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = FieldCheckNotNullAndWithinRangeDouble(mapInfoPointModel.Lat, ServiceRes.Lat, -90, 90); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = FieldCheckNotNullAndWithinRangeDouble(mapInfoPointModel.Lng, ServiceRes.Lng, -180, 180); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.DBCommandOK(mapInfoPointModel.DBCommand); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } return(""); }
public PartialViewResult _TVItemAddOrModify(int ParentTVItemID, int TVItemID, TVTypeEnum TVType) { ViewBag.TVItemModel = null; ViewBag.MapInfoPointModel = null; ViewBag.MapInfoPointModelListPolyline = null; ViewBag.MapInfoPointModelListPolygon = null; ViewBag.ParentTVItemID = ParentTVItemID; ViewBag.TVItemID = TVItemID; ViewBag.TVType = TVType; ViewBag.TVTypeText = _EnumService.GetEnumText_TVTypeEnum(TVType);; if (TVItemID > 0) { ViewBag.IsModify = true; TVItemModel tvItemModel = _TVItemService.GetTVItemModelWithTVItemIDDB(TVItemID); ViewBag.TVItemModel = tvItemModel; MapInfoPointModel mapInfoPointModel = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(TVItemID, TVType, MapInfoDrawTypeEnum.Point).FirstOrDefault(); ViewBag.MapInfoPointModel = mapInfoPointModel; List <MapInfoPointModel> mapInfoPointModelListPolyline = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(TVItemID, TVType, MapInfoDrawTypeEnum.Polyline); ViewBag.MapInfoPointModelListPolyline = mapInfoPointModelListPolyline; List <MapInfoPointModel> mapInfoPointModelListPolygon = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(TVItemID, TVType, MapInfoDrawTypeEnum.Polygon); ViewBag.MapInfoPointModelListPolygon = mapInfoPointModelListPolygon; } return(PartialView()); }
public MapInfoPointModel GetMapInfoPointModelWithMapInfoPointIDDB(int MapInfoPointID) { MapInfoPointModel mapInfoPointModel = (from mi in db.MapInfos from mip in db.MapInfoPoints where mi.MapInfoID == mip.MapInfoID && mip.MapInfoPointID == MapInfoPointID select new MapInfoPointModel { Error = "", MapInfoPointID = mip.MapInfoPointID, DBCommand = (DBCommandEnum)mip.DBCommand, MapInfoID = mip.MapInfoID, Lat = mip.Lat, Lng = mip.Lng, Ordinal = mip.Ordinal, TVItemID = mi.TVItemID, LastUpdateDate_UTC = mip.LastUpdateDate_UTC, LastUpdateContactTVItemID = mip.LastUpdateContactTVItemID }).FirstOrDefault <MapInfoPointModel>(); if (mapInfoPointModel == null) { return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.MapInfoPoint, ServiceRes.MapInfoPointID, MapInfoPointID))); } return(mapInfoPointModel); }
public PartialViewResult _infrastructureEditAll(int InfrastructureTVItemID) { ViewBag.AddressModel = null; InfrastructureModel infrastructureModel = _InfrastructureService.GetInfrastructureModelWithInfrastructureTVItemIDDB(InfrastructureTVItemID); ViewBag.InfrastructureModel = infrastructureModel; if (infrastructureModel.CivicAddressTVItemID != null) { AddressModel addressModel = _AddressService.GetAddressModelWithAddressTVItemIDDB((int)infrastructureModel.CivicAddressTVItemID); ViewBag.AddressModel = addressModel; } MapInfoPointModel mapInfoPointModelInfrastructure = new MapInfoPointModel(); MapInfoPointModel mapInfoPointModelOutfall = new MapInfoPointModel(); if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.WWTP) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.WasteWaterTreatmentPlant, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.LiftStation) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.LiftStation, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.LineOverflow) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.LineOverflow, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.Other) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.OtherInfrastructure, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.SeeOtherMunicipality) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.SeeOtherMunicipality, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } ViewBag.MapInfoPointModelInfrastructure = mapInfoPointModelInfrastructure; ViewBag.MapInfoPointModelOutfall = mapInfoPointModelOutfall; ViewBag.InfrastructureController = _InfrastructureController; return(PartialView()); }
public MapInfoPointModel PostUpdateMapInfoPointDB(MapInfoPointModel mapInfoPointModel) { string retStr = MapInfoPointModelOK(mapInfoPointModel); if (!string.IsNullOrEmpty(retStr)) { return(ReturnError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } MapInfoPoint mapInfoPointToUpdate = GetMapInfoPointWithMapInfoPointIDDB(mapInfoPointModel.MapInfoPointID); if (mapInfoPointToUpdate == null) { return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.MapInfoPoint))); } retStr = FillMapInfoPoint(mapInfoPointToUpdate, mapInfoPointModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } using (TransactionScope ts = new TransactionScope()) { retStr = DoUpdateChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } LogModel logModel = _LogService.PostAddLogForObj("MapInfoPoints", mapInfoPointToUpdate.MapInfoPointID, LogCommandEnum.Change, mapInfoPointToUpdate); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } ts.Complete(); } return(GetMapInfoPointModelWithMapInfoPointIDDB(mapInfoPointToUpdate.MapInfoPointID)); }
// Fill public string FillMapInfoPoint(MapInfoPoint mapInfoPoint, MapInfoPointModel mapInfoPointModel, ContactOK contactOK) { mapInfoPoint.DBCommand = (int)mapInfoPointModel.DBCommand; mapInfoPoint.MapInfoID = mapInfoPointModel.MapInfoID; mapInfoPoint.Ordinal = mapInfoPointModel.Ordinal; mapInfoPoint.Lat = mapInfoPointModel.Lat; mapInfoPoint.Lng = mapInfoPointModel.Lng; mapInfoPoint.LastUpdateDate_UTC = DateTime.UtcNow; if (contactOK == null) { mapInfoPoint.LastUpdateContactTVItemID = 2; } else { mapInfoPoint.LastUpdateContactTVItemID = contactOK.ContactTVItemID; } return(""); }
// Post public MapInfoPointModel PostAddMapInfoPointDB(MapInfoPointModel mapInfoPointModel) { string retStr = MapInfoPointModelOK(mapInfoPointModel); if (!string.IsNullOrEmpty(retStr)) { return(ReturnError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } MapInfoPoint mapInfoPointNew = new MapInfoPoint(); retStr = FillMapInfoPoint(mapInfoPointNew, mapInfoPointModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } using (TransactionScope ts = new TransactionScope()) { db.MapInfoPoints.Add(mapInfoPointNew); retStr = DoAddChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } LogModel logModel = _LogService.PostAddLogForObj("MapInfoPoints", mapInfoPointNew.MapInfoPointID, LogCommandEnum.Add, mapInfoPointNew); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } ts.Complete(); } return(GetMapInfoPointModelWithMapInfoPointIDDB(mapInfoPointNew.MapInfoPointID)); }
public PartialViewResult _infrastructureInfo(string Q) { SetArgs(Q); ViewBag.URLModel = urlModel; ViewBag.AddressModel = null; InfrastructureModel infrastructureModel = _InfrastructureService.GetInfrastructureModelWithInfrastructureTVItemIDDB(urlModel.TVItemIDList[0]); ViewBag.InfrastructureModel = infrastructureModel; if (infrastructureModel.CivicAddressTVItemID != null) { AddressModel addressModel = _AddressService.GetAddressModelWithAddressTVItemIDDB((int)infrastructureModel.CivicAddressTVItemID); ViewBag.AddressModel = addressModel; } MapInfoPointModel mapInfoPointModelInfrastructure = new MapInfoPointModel(); MapInfoPointModel mapInfoPointModelOutfall = new MapInfoPointModel(); if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.WWTP) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(urlModel.TVItemIDList[0], TVTypeEnum.WasteWaterTreatmentPlant, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(urlModel.TVItemIDList[0], TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.LiftStation) { mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(urlModel.TVItemIDList[0], TVTypeEnum.LiftStation, MapInfoDrawTypeEnum.Point).FirstOrDefault(); mapInfoPointModelOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(urlModel.TVItemIDList[0], TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); } ViewBag.MapInfoPointModelInfrastructure = mapInfoPointModelInfrastructure; ViewBag.MapInfoPointModelOutfall = mapInfoPointModelOutfall; ViewBag.InfrastructureController = _InfrastructureController; ViewBag.IsShowMoreInfo = (GetURLVarShowEnumStr(URLVarShowEnum.ShowMoreInfo) == "0" ? false : true); ViewBag.IsShowMap = (GetURLVarShowEnumStr(URLVarShowEnum.ShowMap) == "0" ? false : true); return(PartialView()); }
public ActionResult _mwqmSite(string Q) { List <string> OptionListTxt = new List <string>() { "10", "15", "20", "25", "30", "35", "40" }; SetArgs(Q); ViewBag.URLModel = urlModel; if (!OptionListTxt.Contains(urlModel.VariableShow.Substring(0, 2))) { urlModel.VariableShow = "30" + urlModel.VariableShow.Substring(2); } ViewBag.MWQMController = _MWQMController; MWQMSiteModel mwqmSiteModel = _MWQMSiteService.GetMWQMSiteModelWithMWQMSiteTVItemIDDB(urlModel.TVItemIDList[0]); ViewBag.MWQMSiteModelCurrent = mwqmSiteModel; TVItemModel tvItemModelCurrent = _TVItemService.GetTVItemModelWithTVItemIDDB(urlModel.TVItemIDList[0]); ViewBag.TVItemModelCurrent = tvItemModelCurrent; ViewBag.NumberOfSample = int.Parse(GetURLVarShowEnumStr(URLVarShowEnum.NumberOfSampleDecade) + GetURLVarShowEnumStr(URLVarShowEnum.NumberOfSampleUnit)); ViewBag.IsMoreInfo = (GetURLVarShowEnumStr(URLVarShowEnum.ShowMoreInfo) == "0" ? false : true); List <MapInfoPointModel> mapInfoPointModelList = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(tvItemModelCurrent.TVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point); MapInfoPointModel mapInfoPointModel = new MapInfoPointModel(); if (mapInfoPointModelList.Count > 0) { mapInfoPointModel = mapInfoPointModelList[0]; } ViewBag.MapInfoPointModel = mapInfoPointModel; return(PartialView()); }
public PartialViewResult _mwqmSiteAddOrModify(int SubsectorTVItemID, int MWQMSiteTVItemID) { ViewBag.SubsectorTVItemID = SubsectorTVItemID; ViewBag.MWQMSiteTVItemID = MWQMSiteTVItemID; ViewBag.MapInfoPointModel = null; ViewBag.TVItemModel = null; ViewBag.MWQMController = _MWQMController; MWQMSiteModel mwqmSiteModel = _MWQMSiteService.GetMWQMSiteModelWithMWQMSiteTVItemIDDB(MWQMSiteTVItemID); ViewBag.MWQMSiteModel = mwqmSiteModel; MapInfoPointModel mapInfoPointModel = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(MWQMSiteTVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point).FirstOrDefault(); ViewBag.MapInfoPointModel = mapInfoPointModel; TVItemModel tvItemModel = _TVItemService.GetTVItemModelWithTVItemIDDB(MWQMSiteTVItemID); ViewBag.TVItemModel = tvItemModel; return(PartialView()); }
// Post public MWQMSiteModel MWQMSiteSaveAllDB(FormCollection fc) { //int tempInt = 0; int SubsectorTVItemID = 0; int MWQMSiteTVItemID = 0; bool IsActive = true; string MWQMSiteTVText = ""; string MWQMSiteNumber = ""; string MWQMSiteDescription = ""; double Lat = 0.0D; double Lng = 0.0D; int tempInt = 0; ContactOK contactOK = IsContactOK(); if (!string.IsNullOrWhiteSpace(contactOK.Error)) { return(ReturnError(contactOK.Error)); } int.TryParse(fc["SubsectorTVItemID"], out SubsectorTVItemID); if (SubsectorTVItemID == 0) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.SubsectorTVItemID))); } TVItemModel tvItemModelSubsector = _TVItemService.GetTVItemModelWithTVItemIDDB(SubsectorTVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelSubsector.Error)) { return(ReturnError(tvItemModelSubsector.Error)); } int.TryParse(fc["MWQMSiteTVItemID"], out MWQMSiteTVItemID); // could be 0 if 0 then we need to add the new MWQMSite MWQMSiteModel mwqmSiteNewOrToChange = new MWQMSiteModel(); if (fc["IsActive"] != null) { IsActive = true; } else { IsActive = false; } if (MWQMSiteTVItemID != 0) { mwqmSiteNewOrToChange = GetMWQMSiteModelWithMWQMSiteTVItemIDDB(MWQMSiteTVItemID); if (!string.IsNullOrWhiteSpace(mwqmSiteNewOrToChange.Error)) { return(ReturnError(mwqmSiteNewOrToChange.Error)); } } mwqmSiteNewOrToChange.DBCommand = DBCommandEnum.Original; MWQMSiteTVText = fc["MWQMSiteTVText"]; if (string.IsNullOrWhiteSpace(MWQMSiteTVText)) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.MWQMSiteTVText))); } if (MWQMSiteTVText.Contains("#")) { return(ReturnError(string.Format(ServiceRes.NameOfItemShouldNotContainThe_Character, "#"))); } mwqmSiteNewOrToChange.MWQMSiteTVText = MWQMSiteTVText; MWQMSiteNumber = fc["MWQMSiteNumber"]; if (string.IsNullOrWhiteSpace(MWQMSiteNumber)) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.MWQMSiteNumber))); } mwqmSiteNewOrToChange.MWQMSiteNumber = MWQMSiteNumber; List <TVItemModel> tvItemModelMWQMSiteList = _TVItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(SubsectorTVItemID, TVTypeEnum.MWQMSite); foreach (TVItemModel tvItemModelMWQMSite in tvItemModelMWQMSiteList) { if (tvItemModelMWQMSite.TVItemID != MWQMSiteTVItemID) { MWQMSiteModel mwqmSiteModel = GetMWQMSiteModelWithMWQMSiteTVItemIDDB(tvItemModelMWQMSite.TVItemID); if (!string.IsNullOrWhiteSpace(mwqmSiteModel.Error)) { return(ReturnError(mwqmSiteModel.Error)); } if (mwqmSiteModel.MWQMSiteNumber == MWQMSiteNumber) { return(ReturnError(string.Format(ServiceRes.MWQMSiteNumberHasToBeUniqueForSubsector))); } } } MWQMSiteDescription = fc["MWQMSiteDescription"]; if (string.IsNullOrWhiteSpace(MWQMSiteDescription)) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.MWQMSiteDescription))); } mwqmSiteNewOrToChange.MWQMSiteDescription = MWQMSiteDescription; int.TryParse(fc["MWQMSiteLatestClassification"], out tempInt); if (tempInt == 0) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.MWQMSiteLatestClassification))); } mwqmSiteNewOrToChange.MWQMSiteLatestClassification = (MWQMSiteLatestClassificationEnum)tempInt; double.TryParse(fc["Lat"], out Lat); if (Lat == 0.0D) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.Lat))); } double.TryParse(fc["Lng"], out Lng); if (Lng == 0.0D) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.Lng))); } List <Coord> coordList = new List <Coord>() { new Coord() { Lat = (float)Lat, Lng = (float)Lng, Ordinal = 0 } }; MWQMSiteModel mwqmSiteModelRet = new MWQMSiteModel(); using (TransactionScope ts = new TransactionScope()) { if (MWQMSiteTVItemID == 0) { TVItemModel tvItemModelNewMWQMSite = _TVItemService.PostAddChildTVItemDB(SubsectorTVItemID, MWQMSiteTVText, TVTypeEnum.MWQMSite); if (!string.IsNullOrWhiteSpace(tvItemModelNewMWQMSite.Error)) { return(ReturnError(tvItemModelNewMWQMSite.Error)); } mwqmSiteNewOrToChange.MWQMSiteTVItemID = tvItemModelNewMWQMSite.TVItemID; mwqmSiteModelRet = PostAddMWQMSiteDB(mwqmSiteNewOrToChange); if (!string.IsNullOrWhiteSpace(mwqmSiteModelRet.Error)) { return(ReturnError(mwqmSiteModelRet.Error)); } } else { mwqmSiteModelRet = PostUpdateMWQMSiteDB(mwqmSiteNewOrToChange); if (!string.IsNullOrWhiteSpace(mwqmSiteModelRet.Error)) { return(ReturnError(mwqmSiteModelRet.Error)); } } List <MapInfoPointModel> mapInfoPointModelList = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(mwqmSiteModelRet.MWQMSiteTVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point); if (mapInfoPointModelList.Count == 0) { MapInfoModel mapInfoModelRet = _MapInfoService.CreateMapInfoObjectDB(coordList, MapInfoDrawTypeEnum.Point, TVTypeEnum.MWQMSite, mwqmSiteModelRet.MWQMSiteTVItemID); if (!string.IsNullOrWhiteSpace(mapInfoModelRet.Error)) { return(ReturnError(mapInfoModelRet.Error)); } } else { mapInfoPointModelList[0].Lat = coordList[0].Lat; mapInfoPointModelList[0].Lng = coordList[0].Lng; MapInfoPointModel mapInfoPointModelRet = _MapInfoService._MapInfoPointService.PostUpdateMapInfoPointDB(mapInfoPointModelList[0]); if (!string.IsNullOrWhiteSpace(mapInfoPointModelRet.Error)) { return(ReturnError(mapInfoPointModelRet.Error)); } } TVItemModel tvItemModel = _TVItemService.GetTVItemModelWithTVItemIDDB(mwqmSiteModelRet.MWQMSiteTVItemID); if (!string.IsNullOrWhiteSpace(tvItemModel.Error)) { return(ReturnError(tvItemModel.Error)); } tvItemModel.IsActive = IsActive; tvItemModel.TVText = MWQMSiteTVText; TVItemModel tvItemModelRet = _TVItemService.PostUpdateTVItemDB(tvItemModel); if (!string.IsNullOrWhiteSpace(tvItemModelRet.Error)) { return(ReturnError(tvItemModelRet.Error)); } ts.Complete(); } return(mwqmSiteModelRet); }
// Post public PolSourceSiteModel PolSourceSiteAddOrModifyDB(FormCollection fc) { int tempInt = 0; int ParentTVItemID = 0; int PolSourceSiteTVItemID = 0; bool IsActive = false; bool IsPointSource = false; double Lat = 0.0D; double Lng = 0.0D; ContactOK contactOK = IsContactOK(); if (!string.IsNullOrWhiteSpace(contactOK.Error)) { return(ReturnError(contactOK.Error)); } if (string.IsNullOrWhiteSpace(fc["ParentTVItemID"])) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.ParentTVItemID))); } int.TryParse(fc["ParentTVItemID"], out ParentTVItemID); if (ParentTVItemID == 0) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.ParentTVItemID))); } if (string.IsNullOrWhiteSpace(fc["PolSourceSiteTVItemID"])) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.PolSourceSiteTVItemID))); } int.TryParse(fc["PolSourceSiteTVItemID"], out PolSourceSiteTVItemID); // PolSourceSiteTVItemID == 0 ==> Add // PolSourceSiteTVItemID > 0 ==> Modify TVItemModel tvItemModelPolSource = null; if (PolSourceSiteTVItemID != 0) { tvItemModelPolSource = _TVItemService.GetTVItemModelWithTVItemIDDB(PolSourceSiteTVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelPolSource.Error)) { return(ReturnError(tvItemModelPolSource.Error)); } } PolSourceSiteModel polSourceSiteNewOrToChange = new PolSourceSiteModel(); if (PolSourceSiteTVItemID != 0) { polSourceSiteNewOrToChange = GetPolSourceSiteModelWithPolSourceSiteTVItemIDDB(PolSourceSiteTVItemID); if (!string.IsNullOrWhiteSpace(polSourceSiteNewOrToChange.Error)) { return(ReturnError(polSourceSiteNewOrToChange.Error)); } } polSourceSiteNewOrToChange.DBCommand = DBCommandEnum.Original; if (string.IsNullOrWhiteSpace(fc["IsActive"])) { IsActive = false; } else { IsActive = true; } if (!IsActive) { int.TryParse(fc["InactiveReason"], out tempInt); if (tempInt == 0) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.InactiveReason))); } polSourceSiteNewOrToChange.InactiveReason = (PolSourceInactiveReasonEnum)tempInt; } else { polSourceSiteNewOrToChange.InactiveReason = null; } if (string.IsNullOrWhiteSpace(fc["IsPointSource"])) { IsPointSource = false; } else { IsPointSource = true; } polSourceSiteNewOrToChange.IsPointSource = IsPointSource; double.TryParse(fc["Lat"], out Lat); if (Lat == 0.0D) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.Lat))); } double.TryParse(fc["Lng"], out Lng); if (Lng == 0.0D) { return(ReturnError(string.Format(ServiceRes._IsRequired, ServiceRes.Lng))); } List <Coord> coordList = new List <Coord>() { new Coord() { Lat = (float)Lat, Lng = (float)Lng, Ordinal = 0 } }; using (TransactionScope ts = new TransactionScope()) { string ObservationInfo = ((int)PolSourceObsInfoEnum.SourceStart).ToString() + ","; List <int> obsIntList = ObservationInfo.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList(); string ObservationLanguageTVText = ServiceRes.Error; string TVText = _BaseEnumService.GetEnumText_PolSourceObsInfoTextEnum(PolSourceObsInfoEnum.Error); int NextSiteNumber = 0; if (PolSourceSiteTVItemID == 0) { NextSiteNumber = GetNextAvailableSiteNumberWithParentTVItemIDDB(ParentTVItemID); polSourceSiteNewOrToChange.Site = NextSiteNumber; TVText = TVText + " - " + "000000".Substring(0, "000000".Length - NextSiteNumber.ToString().Length) + NextSiteNumber.ToString(); TVItemModel tvItemModelNewPolSourceSite = _TVItemService.PostAddChildTVItemDB(ParentTVItemID, TVText, TVTypeEnum.PolSourceSite); if (!string.IsNullOrWhiteSpace(tvItemModelNewPolSourceSite.Error)) { return(ReturnError(tvItemModelNewPolSourceSite.Error)); } polSourceSiteNewOrToChange.PolSourceSiteTVItemID = tvItemModelNewPolSourceSite.TVItemID; polSourceSiteNewOrToChange.PolSourceSiteTVText = TVText; polSourceSiteNewOrToChange = PostAddPolSourceSiteDB(polSourceSiteNewOrToChange); if (!string.IsNullOrWhiteSpace(polSourceSiteNewOrToChange.Error)) { return(ReturnError(polSourceSiteNewOrToChange.Error)); } // Automatically add one Pollution Source Observation for today PolSourceObservationModel polSourceObservationModelNew = new PolSourceObservationModel() { DBCommand = DBCommandEnum.Original, PolSourceSiteID = polSourceSiteNewOrToChange.PolSourceSiteID, ObservationDate_Local = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), ContactTVItemID = contactOK.ContactTVItemID, Observation_ToBeDeleted = "", }; PolSourceObservationModel polSourceObservationModelRet = _PolSourceObservationService.PostAddPolSourceObservationDB(polSourceObservationModelNew); if (!string.IsNullOrWhiteSpace(polSourceObservationModelRet.Error)) { return(ReturnError(polSourceObservationModelRet.Error)); } // Automatically add one Pollution Source Observation Issue PolSourceObservationIssueModel polSourceObservationIssueModelNew = new PolSourceObservationIssueModel(); polSourceObservationIssueModelNew.DBCommand = DBCommandEnum.Original; polSourceObservationIssueModelNew.PolSourceObservationID = polSourceObservationModelRet.PolSourceObservationID; polSourceObservationIssueModelNew.ObservationInfo = ObservationInfo; polSourceObservationIssueModelNew.Ordinal = 0; PolSourceObservationIssueModel polSourceObservationIssueModelRet = _PolSourceObservationService._PolSourceObservationIssueService.PostAddPolSourceObservationIssueDB(polSourceObservationIssueModelNew); if (!string.IsNullOrWhiteSpace(polSourceObservationIssueModelRet.Error)) { return(ReturnError(polSourceObservationIssueModelRet.Error)); } // doing the other language foreach (LanguageEnum lang in LanguageListAllowable.Where(c => c != LanguageRequest)) { TVItemService tvItemService = new TVItemService(lang, _TVItemService.User); Thread.CurrentThread.CurrentCulture = new CultureInfo(lang + "-CA"); Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang + "-CA"); ObservationInfo = ((int)PolSourceObsInfoEnum.SourceStart).ToString() + ","; ObservationLanguageTVText = ServiceRes.Error; TVText = _BaseEnumService.GetEnumText_PolSourceObsInfoTextEnum(PolSourceObsInfoEnum.Error); TVText = (string.IsNullOrWhiteSpace(TVText) ? ServiceRes.Error : TVText); if (PolSourceSiteTVItemID == 0) { TVText = TVText + " - " + "000000".Substring(0, "000000".Length - NextSiteNumber.ToString().Length) + NextSiteNumber.ToString(); } else { TVText = TVText + " - " + "000000".Substring(0, "000000".Length - polSourceSiteNewOrToChange.Site.ToString().Length) + polSourceSiteNewOrToChange.Site.ToString(); } TVItemLanguageModel tvItemLanguageModel = new TVItemLanguageModel(); tvItemLanguageModel.DBCommand = DBCommandEnum.Original; tvItemLanguageModel.Language = lang; tvItemLanguageModel.TVText = TVText; tvItemLanguageModel.TVItemID = polSourceSiteNewOrToChange.PolSourceSiteTVItemID; TVItemLanguageModel tvItemLanguageModelRet = tvItemService._TVItemLanguageService.PostUpdateTVItemLanguageDB(tvItemLanguageModel); if (!string.IsNullOrWhiteSpace(tvItemLanguageModelRet.Error)) { return(ReturnError(tvItemLanguageModelRet.Error)); } Thread.CurrentThread.CurrentCulture = new CultureInfo(LanguageRequest + "-CA"); Thread.CurrentThread.CurrentUICulture = new CultureInfo(LanguageRequest + "-CA"); } } else { polSourceSiteNewOrToChange = PostUpdatePolSourceSiteDB(polSourceSiteNewOrToChange); if (!string.IsNullOrWhiteSpace(polSourceSiteNewOrToChange.Error)) { return(ReturnError(polSourceSiteNewOrToChange.Error)); } } // Adding map info List <MapInfoPointModel> mapInfoPointModelList = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(polSourceSiteNewOrToChange.PolSourceSiteTVItemID, TVTypeEnum.PolSourceSite, MapInfoDrawTypeEnum.Point); if (mapInfoPointModelList.Count == 0) { MapInfoModel mapInfoModelRet = _MapInfoService.CreateMapInfoObjectDB(coordList, MapInfoDrawTypeEnum.Point, TVTypeEnum.PolSourceSite, polSourceSiteNewOrToChange.PolSourceSiteTVItemID); if (!string.IsNullOrWhiteSpace(mapInfoModelRet.Error)) { return(ReturnError(mapInfoModelRet.Error)); } } else { mapInfoPointModelList[0].Lat = coordList[0].Lat; mapInfoPointModelList[0].Lng = coordList[0].Lng; MapInfoPointModel mapInfoPointModelRet = _MapInfoService._MapInfoPointService.PostUpdateMapInfoPointDB(mapInfoPointModelList[0]); if (!string.IsNullOrWhiteSpace(mapInfoPointModelRet.Error)) { return(ReturnError(mapInfoPointModelRet.Error)); } } TVItemModel tvItemModelPolSourceSite = _TVItemService.GetTVItemModelWithTVItemIDDB(polSourceSiteNewOrToChange.PolSourceSiteTVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelPolSourceSite.Error)) { return(ReturnError(tvItemModelPolSourceSite.Error)); } tvItemModelPolSourceSite.IsActive = IsActive; TVItemModel tvItemModelRet = _TVItemService.PostUpdateTVItemDB(tvItemModelPolSourceSite); if (!string.IsNullOrWhiteSpace(tvItemModelRet.Error)) { return(ReturnError(tvItemModelRet.Error)); } ts.Complete(); } return(polSourceSiteNewOrToChange); }
public void InfrastructureController__infrastructureEditAll_Test() { controllerAction = "_infrastructureInfo"; foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture, controllerAction); using (TransactionScope ts = new TransactionScope()) { TVItemModel tvItemModelRoot = tvItemService.GetRootTVItemModelDB(); Assert.AreEqual("", tvItemModelRoot.Error); TVItemModel tvItemModelBouctouche = tvItemService.GetChildTVItemModelWithTVItemIDAndTVTextStartWithAndTVTypeDB(tvItemModelRoot.TVItemID, "Bouctouche", TVTypeEnum.Municipality); Assert.AreEqual("", tvItemModelBouctouche.Error); List <TVItemModel> tvItemModelInfrastructureList = tvItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModelBouctouche.TVItemID, TVTypeEnum.Infrastructure); Assert.IsTrue(tvItemModelInfrastructureList.Count > 0); TVItemModel tvItemModelInfWWTP = new TVItemModel(); InfrastructureModel infrastructureModel = new InfrastructureModel(); foreach (TVItemModel tvItemModel in tvItemModelInfrastructureList) { infrastructureModel = infrastructureService.GetInfrastructureModelWithInfrastructureTVItemIDDB(tvItemModel.TVItemID); Assert.IsTrue(tvItemModelInfrastructureList.Count > 0); if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.WWTP) { break; } } Assert.AreEqual(InfrastructureTypeEnum.WWTP, infrastructureModel.InfrastructureType); List <MapInfoPointModel> mapInfoPointModelWWTPList = mapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(infrastructureModel.InfrastructureTVItemID, TVTypeEnum.WasteWaterTreatmentPlant, MapInfoDrawTypeEnum.Point); Assert.IsTrue(mapInfoPointModelWWTPList.Count > 0); List <MapInfoPointModel> mapInfoPointModelOutfallList = mapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(infrastructureModel.InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point); Assert.IsTrue(mapInfoPointModelOutfallList.Count > 0); string Q = "!View/" + tvItemModelInfrastructureList[0].TVText + "|||" + infrastructureModel.InfrastructureTVItemID; PartialViewResult partialViewResult = controller._infrastructureEditAll(infrastructureModel.InfrastructureTVItemID) as PartialViewResult; Assert.IsNotNull(partialViewResult); InfrastructureModel infrastructureModelRet = (InfrastructureModel)partialViewResult.ViewBag.infrastructureModel; Assert.IsNotNull(infrastructureModelRet); Assert.AreEqual(infrastructureModel.InfrastructureTVItemID, infrastructureModel.InfrastructureTVItemID); Assert.AreEqual(infrastructureModel.DesignFlow_m3_day, infrastructureModel.DesignFlow_m3_day); MapInfoPointModel mapInfoPointModelInfrastructure = (MapInfoPointModel)partialViewResult.ViewBag.MapInfoPointModelInfrastructure; Assert.IsNotNull(mapInfoPointModelInfrastructure); Assert.AreEqual(mapInfoPointModelWWTPList[0].Lat, mapInfoPointModelInfrastructure.Lat); Assert.AreEqual(mapInfoPointModelWWTPList[0].Lng, mapInfoPointModelInfrastructure.Lng); MapInfoPointModel mapInfoPointModelOutfall = (MapInfoPointModel)partialViewResult.ViewBag.MapInfoPointModelOutfall; Assert.IsNotNull(mapInfoPointModelOutfall); Assert.AreEqual(mapInfoPointModelOutfallList[0].Lat, mapInfoPointModelOutfall.Lat); Assert.AreEqual(mapInfoPointModelOutfallList[0].Lng, mapInfoPointModelOutfall.Lng); } } }
public ActionResult MapMoveLabelClearJSON(int SubsectorTVItemID, int TVType, bool OnlyActive) { MapInfoPointModel mapInfoPointModel = _MapInfoService.PostMapMoveLabelClearDB(SubsectorTVItemID, TVType, OnlyActive); return(Json(mapInfoPointModel.Error, JsonRequestBehavior.AllowGet)); }
public ActionResult MapDeleteLabelJSON(int MapInfoID, float Lat, float Lng) { MapInfoPointModel mapInfoPointModel = _MapInfoService.PostMapDeleteLabelDB(MapInfoID, Lat, Lng); return(Json(mapInfoPointModel.Error, JsonRequestBehavior.AllowGet)); }
public PartialViewResult _infrastructureAddOrModify(int TVItemIDMunicipality, int InfrastructureTVItemID, string TVText, bool IsAdd) { ViewBag.TVItemIDMunicipality = TVItemIDMunicipality; ViewBag.InfrastructureTVItemID = InfrastructureTVItemID; ViewBag.TVItemModelMunicipalityList = new TVItemModel(); ViewBag.MapInfoPointModelInfrastructure = null; ViewBag.MapInfoPointModelInfrastructureOutfall = null; InfrastructureModel infrastructureModel = _InfrastructureService.GetInfrastructureModelWithInfrastructureTVItemIDDB(InfrastructureTVItemID); ViewBag.InfrastructureModel = infrastructureModel; TVTypeEnum TVType = TVTypeEnum.Error; MapInfoPointModel mapInfoPointModelInfrastructure = new MapInfoPointModel(); if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.WWTP) { TVType = TVTypeEnum.WasteWaterTreatmentPlant; } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.LiftStation) { TVType = TVTypeEnum.LiftStation; } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.LineOverflow) { TVType = TVTypeEnum.LineOverflow; } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.Other) { TVType = TVTypeEnum.OtherInfrastructure; } else if (infrastructureModel.InfrastructureType == InfrastructureTypeEnum.SeeOtherMunicipality) { TVType = TVTypeEnum.SeeOtherMunicipality; } mapInfoPointModelInfrastructure = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVType, MapInfoDrawTypeEnum.Point).FirstOrDefault(); ViewBag.MapInfoPointModelInfrastructure = mapInfoPointModelInfrastructure; MapInfoPointModel mapInfoPointModelInfrastructureOutfall = new MapInfoPointModel(); mapInfoPointModelInfrastructureOutfall = _MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(InfrastructureTVItemID, TVTypeEnum.Outfall, MapInfoDrawTypeEnum.Point).FirstOrDefault(); ViewBag.MapInfoPointModelInfrastructureOutfall = mapInfoPointModelInfrastructureOutfall; ViewBag.TVText = TVText; ViewBag.InfrastructureController = _InfrastructureController; TVItemModel tvItemModelMunicipality = _TVItemService.GetTVItemModelWithTVItemIDDB(TVItemIDMunicipality); if (string.IsNullOrWhiteSpace(tvItemModelMunicipality.Error)) { List <TVItemModel> tvItemModelParentsList = _TVItemService.GetParentsTVItemModelList(tvItemModelMunicipality.TVPath); foreach (TVItemModel tvItemModel in tvItemModelParentsList) { if (tvItemModel.TVType == TVTypeEnum.Province) { List <TVItemModel> tvItemModelMunicipalityList = _TVItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModel.TVItemID, TVTypeEnum.Municipality); ViewBag.TVItemModelMunicipalityList = tvItemModelMunicipalityList; break; } } } return(PartialView()); }