/// <summary> /// 顯示所有教室資訊 照館別排列 /// </summary> /// <returns></returns> public ActionResult Classroom() { try { //驗證授權:管理員 var pass = roleAuth.AdminAuth(); if (pass == true) { ViewBag.UserName = roleAuth.UserName(); ViewBag.RoleName = "Admin"; } else { TempData["Msg"] = "無權限瀏覽該網頁,請登入會員瀏覽,謝謝!"; return(RedirectToAction("Login", "Home")); } StoreOperation storeOperation = new StoreOperation(); ClassroomOperation classroomOperation = new ClassroomOperation(); //取得所有館別ID var allStore = storeOperation.Get().Select(c => c.StoreNo); //取得所有教室 var allClassroom = classroomOperation.Get(); List <ClassroomViewModel> LstModel = new List <ClassroomViewModel>(); //根據現有館別歸納出各場館下的教室 foreach (var StoreNo in allStore) { ClassroomViewModel model = new ClassroomViewModel(); model.ClassInfo = new List <Dictionary <string, string> >(); //取得同館別的教室 var LstClsRoom = allClassroom.Where(c => c.Store_No.Equals(StoreNo)).Select(c => c); model.StoreNo = StoreNo; model.StoreName = storeOperation.GetName(StoreNo); //取得同館別所有教室的Id及名稱 foreach (var item in LstClsRoom) { var DicClsInfo = new Dictionary <string, string>(); DicClsInfo.Add(item.ClassroomNo, item.Name); model.ClassInfo.Add(DicClsInfo); } LstModel.Add(model); } return(View(LstModel)); } catch (Exception ex) { TempData["Msg"] = ex.ToString(); return(RedirectToAction("Logout", "Home")); } }
/// <summary> /// 顯示我的預約課程紀錄 /// </summary> /// <returns></returns> public ActionResult MyBooking() { try { //驗證授權:一般會員 var pass = roleAuth.UserAuth(); if (pass == true) { ViewBag.UserName = roleAuth.UserName(); ViewBag.RoleName = "User"; } else { TempData["Msg"] = "無權限瀏覽該網頁,請登入會員瀏覽,謝謝!"; return(RedirectToAction("Logout", "Home")); } //取得會員Id var UserEmail = User.Identity.Name; MemberOperation member = new MemberOperation(); var id = member.Get(UserEmail).MemberNo; CourseOperation co = new CourseOperation(); var nowdata = co.GetBooking(id); //尚未結束之預約課程 var pastdata = co.GetPastBooking(id); //已結束之預約課程 CourseTypeOperation cto = new CourseTypeOperation(); ClassroomOperation classroom = new ClassroomOperation(); StoreOperation so = new StoreOperation(); TeacherOperation to = new TeacherOperation(); BookingGroupViewModel booking = new BookingGroupViewModel(); booking.FutureBooking = new List <FutureBookingViewModel>(); booking.PastBooking = new List <PastBookingViewModel>(); foreach (var item in nowdata) { FutureBookingViewModel fbv = new FutureBookingViewModel() { CourseNo = item.CourseNo, //課程代號 CourseName = cto.Get(item.CourseType_No).Name, //課程名稱 Date = item.ClassDate.ToShortDateString(), //日期 Classroom = classroom.Get(item.Classroom_No).Name, //教室 Store = so.GetName(classroom.Get(item.Classroom_No).Store_No), //場館 Time = item.StartTime.ToShortTimeString() + " ~ " + item.EndTime.ToShortTimeString(), //上課時間 Teacher = to.GetName(item.Teacher_No) //教練名字 }; booking.FutureBooking.Add(fbv); } foreach (var item in pastdata) { PastBookingViewModel pbv = new PastBookingViewModel() { CourseNo = item.CourseNo, //課程代號 CourseName = cto.Get(item.CourseType_No).Name, //課程名稱 Date = item.ClassDate.ToShortDateString(), //日期 Classroom = classroom.Get(item.Classroom_No).Name, //教室 Store = so.GetName(classroom.Get(item.Classroom_No).Store_No), //場館 Time = item.StartTime.ToShortTimeString() + " ~ " + item.EndTime.ToShortTimeString(), //上課時間 Teacher = to.GetName(item.Teacher_No) //教練名字 }; booking.PastBooking.Add(pbv); } return(View(booking)); } catch (Exception ex) { TempData["Msg"] = ex.ToString(); return(RedirectToAction("Logout", "Home")); } }