From d84629575f443fd7c8fab5ecab7f6749de749d85 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 15 Jul 2021 09:10:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=BB=E7=AB=99=E9=81=B8=E5=96=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/MyBaseController.cs | 48 ++++++++++++++++++- SolarPower/Views/PowerStation/Index.cshtml | 1 - .../PowerStation/PowerStationEdit.cshtml | 1 - SolarPower/Views/Shared/_Layout.cshtml | 13 +++-- SolarPower/Views/User/Index.cshtml | 2 +- 5 files changed, 57 insertions(+), 8 deletions(-) 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 @@ diff --git a/SolarPower/Views/User/Index.cshtml b/SolarPower/Views/User/Index.cshtml index 026935e..07be45a 100644 --- a/SolarPower/Views/User/Index.cshtml +++ b/SolarPower/Views/User/Index.cshtml @@ -1,6 +1,6 @@ @{ ViewData["MainNum"] = "7"; - ViewData["SubNum"] = "3"; + ViewData["SubNum"] = "2"; ViewData["Title"] = "帳號管理"; }