From 1a8b9fc22a95a546bd708e6aebdc59dc0df96d05 Mon Sep 17 00:00:00 2001 From: Janie <109517022+Janie06@users.noreply.github.com> Date: Fri, 17 Feb 2023 12:49:12 +0800 Subject: [PATCH] =?UTF-8?q?[WHAT]=20=E6=9C=83=E5=93=A1=20Booking=20Catgory?= =?UTF-8?q?=20API=20[WHY]=20=E9=96=8B=E7=99=BC=20ShowEasy=20=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EasyBL.WEBAPP/ShowEasy/BookingService.cs | 89 ++++++++++--------- .../ShowEasy/ONSiteMaintain_QryService.cs | 49 +++++++++- 2 files changed, 94 insertions(+), 44 deletions(-) diff --git a/EuroTran/EasyBL.WEBAPP/ShowEasy/BookingService.cs b/EuroTran/EasyBL.WEBAPP/ShowEasy/BookingService.cs index 88f41bd..3fa02d9 100644 --- a/EuroTran/EasyBL.WEBAPP/ShowEasy/BookingService.cs +++ b/EuroTran/EasyBL.WEBAPP/ShowEasy/BookingService.cs @@ -63,10 +63,10 @@ namespace EasyBL.WEBAPP.SYS #endregion 類別選單(List 類別選單查詢) - #region 類別選單(List 類別選單查詢) + #region 子類別查詢API (服務有包含該類別才列出) /// - /// 類別選單(List 類別選單查詢) + /// 子類別查詢API (服務有包含該類別才列出) /// /// /// @@ -79,64 +79,67 @@ namespace EasyBL.WEBAPP.SYS { do { - //Alina:有錯誤先注釋掉 - ////用Account取Member的MemberID - //MemberMaintain_QryService member_qry = new MemberMaintain_QryService(); - //var member = member_qry.QueryOneByAccount(Account); + //用Account取Member的MemberID + MemberMaintain_QryService member_qry = new MemberMaintain_QryService(); + var member = member_qry.QueryOneByAccount(Account); - ////取Member所有的訂單 - //BookingMaintain_QryService booking_qry = new BookingMaintain_QryService(); + //取Member所有的訂單 + BookingMaintain_QryService booking_qry = new BookingMaintain_QryService(); - //var allBooking = booking_qry.FindAllByIDsAsDictionary(member.MemberID); + var allBooking = booking_qry.FindAllByIDsAsDictionary(member.MemberID); - //var allBookingServiceList = booking_qry.FindAllByIDsAsDictionary(member.MemberID).Values.ToList().Where(w => !string.IsNullOrEmpty(w.ServiceID)).Select(s => s.ServiceID).ToList(); + var allBookingServiceList = booking_qry.FindAllByIDsAsDictionary(member.MemberID).Values.ToList().Where(w => !string.IsNullOrEmpty(w.ServiceID)).Select(s => s.ServiceID).ToList(); - ////取所有category - //ServiceSubCategoryMaintain_QryService serviceSub_qry = new ServiceSubCategoryMaintain_QryService(); - //var subCategory = serviceSub_qry.FindAllByIDsAsDictionary("", LangType); + //取所有category + ServiceSubCategoryMaintain_QryService serviceSub_qry = new ServiceSubCategoryMaintain_QryService(); + var subCategory = serviceSub_qry.FindAllByIDsAsDictionary("", LangType); - ////取得所有OnSiteService - //ONSiteMaintain_QryService onSiteService_qry = new ONSiteMaintain_QryService(); - //var allService = onSiteService_qry.FindAllByIDsAsDictionary(""); + //取得所有OnSiteService + ONSiteMaintain_QryService onSiteService_qry = new ONSiteMaintain_QryService(); + var allService = onSiteService_qry.FindAllByIDsAsDictionary(""); - //var ServiceIDSet = new HashSet(); //去重複值 - //var CategoryDic = new Dictionary(); + var ServiceIDSet = new HashSet(); //去重複值 + var CategoryDic = new Dictionary(); - //foreach (var ServiceID in allBookingServiceList) { + foreach (var ServiceID in allBookingServiceList) + { - // SETB_PDT_ONSiteBaseInfo Service = new SETB_PDT_ONSiteBaseInfo(); + SETB_PDT_ONSiteBaseInfo Service = new SETB_PDT_ONSiteBaseInfo(); - // if (allService.ContainsKey(ServiceID)) { - // Service = allService[ServiceID]; - // } + if (allService.ContainsKey(ServiceID)) + { + Service = allService[ServiceID]; + } - // var SubCategoryIDList = new List(); + var SubCategoryIDList = new List(); - // if (!string.IsNullOrEmpty(Service.SubCategoryID)) { - // SubCategoryIDList = JsonConvert.DeserializeObject>(Service.SubCategoryID); - // } + if (!string.IsNullOrEmpty(Service.SubCategoryID)) + { + SubCategoryIDList = JsonConvert.DeserializeObject>(Service.SubCategoryID); + } - // foreach(var subCategoryID in SubCategoryIDList) - // { + foreach (var subCategoryID in SubCategoryIDList) + { - // SETB_SYS_Category category = new SETB_SYS_Category(); + SETB_SYS_Category category = new SETB_SYS_Category(); - // if (subCategory.ContainsKey(subCategoryID)) { - // category = subCategory[subCategoryID]; //用subCategoryID在subCategory內找 - // } + if (subCategory.ContainsKey(subCategoryID)) + { + category = subCategory[subCategoryID]; //用subCategoryID在subCategory內找 + } - // CategoryDTO categoryDTO = new CategoryDTO(); + CategoryDTO categoryDTO = new CategoryDTO(); - // categoryDTO.CategoryID = category.CategoryID; - // categoryDTO.CategoryName = category.CategoryName; + categoryDTO.CategoryID = category.CategoryID; + categoryDTO.CategoryName = category.CategoryName; - // CategoryDic[categoryDTO.CategoryID] = categoryDTO; //把categoryDTO.CategoryID當作key,把value(categoryDTO)存進CategoryDic - // //存到Dictionary內會去重複值。不用額外用HashSet - // } - //} + CategoryDic[categoryDTO.CategoryID] = categoryDTO; //把categoryDTO.CategoryID當作key,把value(categoryDTO)存進CategoryDic + //存到Dictionary內會去重複值。不用額外用HashSet + } + } - //srm = new SuccessResponseMessage(null, null); - //srm.DATA.Add(BLWording.REL, CategoryDic.Values.ToList()); + srm = new SuccessResponseMessage(null, null); + srm.DATA.Add(BLWording.REL, CategoryDic.Values.ToList()); } while (false); } @@ -155,7 +158,7 @@ namespace EasyBL.WEBAPP.SYS } - #endregion 類別選單(List 類別選單查詢) + #endregion 子類別查詢API (服務有包含該類別才列出) } } \ No newline at end of file diff --git a/EuroTran/EasyBL.WEBAPP/ShowEasy/ONSiteMaintain_QryService.cs b/EuroTran/EasyBL.WEBAPP/ShowEasy/ONSiteMaintain_QryService.cs index c358009..bbfd0fc 100644 --- a/EuroTran/EasyBL.WEBAPP/ShowEasy/ONSiteMaintain_QryService.cs +++ b/EuroTran/EasyBL.WEBAPP/ShowEasy/ONSiteMaintain_QryService.cs @@ -1942,5 +1942,52 @@ namespace EasyBL.WEBAPP.ShowEasy } + //QueryALLOnSiteServiceAsDic + public Dictionary FindAllByIDsAsDictionary(string ServiceID) + { + + string sMsg = null; + + var db = SugarBase.GetIntance(); + + Dictionary saServiceDic = new Dictionary(); + + try + { + do + { + + var saServiceList = db.Queryable() + .Where(t1 => t1.Effective == "Y") + .WhereIF(!string.IsNullOrEmpty(ServiceID), t1 => t1.ServiceID == ServiceID) + .Select((t1) => new SETB_PDT_ONSiteBaseInfo + { + + ServiceID = SqlFunc.GetSelfAndAutoFill(t1.ServiceID) + + }) + .ToList(); + + foreach (var service in saServiceList) + { + saServiceDic[service.ServiceID] = service; + } + + return saServiceDic; + + } while (false); + } + catch (Exception ex) + { + sMsg = Util.GetLastExceptionMsg(ex); + + } + + return saServiceDic; + + } + } -} \ No newline at end of file +} + +