diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index 3f93fd2..15fa25b 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -97,7 +97,53 @@ namespace SolarPower.Controllers //取得當前使用者可以查看的電站 - ViewBag.myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser); + var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser); + ViewBag.myPowerStationSummaries = myPowerStationSummaries; + + if (controllerName == "PowerStation" && actionName == "Edit") + { + //電站資訊的各電站 + string stationId_param = filterContext.HttpContext.Request.Query["stationId"]; + + int stationId = stationId_param == "new" ? 0 : int.Parse(stationId_param); + + + if (stationId > 0) + { + var hasSubTagNum = false; + int i = 0; + foreach(var myPowerStationSummary in myPowerStationSummaries) + { + if (hasSubTagNum) + { + break; + } + int j = 0; + foreach(var myPowerStation in myPowerStationSummary.MyPowerStations) + { + if(myPowerStation.PowerStationId == stationId) + { + ViewData["SubNum"] = i; + ViewData["TagNum"] = j; + hasSubTagNum = true; + break; + } + j++; + } + i++; + } + } + else + { + //電站管理的新增電站 + ViewData["SubNum"] = myPowerStationSummaries.Count(); + ViewData["TagNum"] = 0; + } + }else if(controllerName == "PowerStation" && actionName == "Index") + { + ViewData["SubNum"] = myPowerStationSummaries.Count(); + ViewData["TagNum"] = 0; + } ViewBag.auths = auth_arr; diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index 386e869..bf3dd01 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -1,6 +1,5 @@ @{ ViewData["MainNum"] = "2"; - ViewData["SubNum"] = "1"; ViewData["Title"] = "電站管理"; } diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index 7524fde..63bbda7 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -1,6 +1,5 @@ @{ ViewData["MainNum"] = "2"; - ViewData["SubNum"] = "1"; ViewData["Title"] = "電站管理"; } diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 1ad12b3..05c984a 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -131,26 +131,31 @@