示例#1
0
        /// <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"));
            }
        }
示例#2
0
        /// <summary>
        /// 各館資訊
        /// </summary>
        /// <returns></returns>
        //[CommonAuthorize]
        public ActionResult StoreInfo()
        {
            try
            {
                //驗證授權:一般會員及訪客
                //RoleAuthManager roleAuth = new RoleAuthManager();
                var pass = roleAuth.UserGuestAuth();
                if (pass == 0)
                {
                    ViewBag.UserName = roleAuth.UserName();
                }
                else if (pass == 1)
                {
                    ViewBag.UserName = roleAuth.UserName();
                    ViewBag.RoleName = "User";
                }
                else if (pass == 2)
                {
                    ViewBag.RoleName = "Admin";
                    ViewBag.UserName = roleAuth.UserName();
                    TempData["Msg"]  = "無權限瀏覽該網頁,請登入會員或以訪客身分瀏覽,謝謝!";
                    return(RedirectToAction("Login", "Home"));
                }

                StoreOperation storeOp  = new StoreOperation();
                var            AllStore = storeOp.Get();//取得所有館別

                List <StoreInfoViewModel> stores = new List <StoreInfoViewModel>();

                foreach (var item in AllStore)
                {
                    StoreInfoViewModel storeVModel = new StoreInfoViewModel();
                    storeVModel.Name          = item.Name;
                    storeVModel.Address       = item.Address;
                    storeVModel.Tel           = item.Tel;
                    storeVModel.Service       = item.ServiceInfo;
                    storeVModel.Parking       = item.ParkingInfo;
                    storeVModel.MemberInCount = item.AccessLimit;

                    stores.Add(storeVModel);
                }

                return(View(stores));
            }
            catch (Exception ex)
            {
                TempData["Msg"] = ex.ToString();
                return(View());
            }
        }
示例#3
0
        /// <summary>
        /// 取得所有館別資料
        /// </summary>
        /// <returns></returns>
        public ActionResult Store()
        {
            try
            {
                //驗證授權:管理員
                var pass = roleAuth.AdminAuth();
                if (pass == true)
                {
                    ViewBag.UserName = roleAuth.UserName();
                    ViewBag.RoleName = "Admin";
                }
                else
                {
                    TempData["Msg"] = "無權限瀏覽該網頁,請登入會員瀏覽,謝謝!";
                    return(RedirectToAction("Login", "Home"));
                }

                StoreOperation op       = new StoreOperation();
                var            allStore = op.Get();

                List <StoreViewModel> lstModel = new List <StoreViewModel>();
                foreach (var item in allStore)
                {
                    StoreViewModel model = new StoreViewModel();
                    model.StoreNo     = item.StoreNo;
                    model.Name        = item.Name;
                    model.Address     = item.Address;
                    model.Tel         = item.Tel;
                    model.ServiceInfo = item.ServiceInfo;
                    model.ParkingInfo = item.ParkingInfo;
                    model.MemberInCnt = item.MemberInCnt.ToString();
                    model.AccessLimit = item.AccessLimit.ToString();

                    lstModel.Add(model);
                }

                return(View(lstModel));
            }

            catch (Exception ex)
            {
                TempData["Msg"] = ex.ToString();
                return(RedirectToAction("Logout", "Home"));
            }
        }
示例#4
0
        }                                        //選擇館別

        public void listStoreItems()
        {
            List <StoreCheckboxListItem> checkList = new List <StoreCheckboxListItem>();

            //從館別資料表取得目前所有館別資料
            StoreOperation store    = new StoreOperation();
            var            allStore = store.Get().ToList();

            //根據館別新增對應的Checkbox
            foreach (Store item in allStore)
            {
                checkList.AddRange(new[] {
                    new StoreCheckboxListItem()
                    {
                        DisplayText = item.Name, No = item.StoreNo, IsChecked = false
                    }
                });
            }

            stores = checkList;
        }
示例#5
0
        //[CommonAuthorize]
        public ActionResult Index()
        {
            try
            {
                RoleAuthManager roleAuth = new RoleAuthManager();
                var             pass     = roleAuth.UserGuestAuth();
                if (pass == 0)
                {
                    ViewBag.UserName = roleAuth.UserName();
                }
                else if (pass == 1)
                {
                    ViewBag.UserName = roleAuth.UserName();
                    ViewBag.RoleName = "User";
                }
                else if (pass == 2)
                {
                    ViewBag.RoleName = "Admin";
                    ViewBag.UserName = roleAuth.UserName();
                    TempData["Msg"]  = "無權限瀏覽該網頁,請登入會員或以訪客身分瀏覽,謝謝!";
                    return(RedirectToAction("Login", "Home"));
                }

                StoreOperation        storeOp           = new StoreOperation();
                var                   AllStore          = storeOp.Get();           //取得所有館別
                ClassroomOperation    clsroomOp         = new ClassroomOperation();
                var                   AllStoreClassRoom = clsroomOp.Get(AllStore); //取得所有館別的教室
                CourseOperation       crsItemOp         = new CourseOperation();
                CourseTypeOperation   crsOp             = new CourseTypeOperation();
                List <IndexViewModel> Lstmodel          = new List <IndexViewModel>();

                //取得每個館別的資料
                foreach (var store in AllStore)
                {
                    IndexViewModel model = new IndexViewModel();
                    model.CourseInfo = new List <string>();

                    model.Store       = store.Name;
                    model.AccessLimit = store.AccessLimit.ToString();
                    model.AccessNow   = store.MemberInCnt.ToString();

                    //取得該館的所有教室
                    var StoreClassRoom = clsroomOp.Get(store);

                    //若教室為一對一教練課用 跳過
                    foreach (var Room in StoreClassRoom)
                    {
                        if (Room.Name.Equals("一對一場地"))
                        {
                            continue;
                        }

                        var RoomName  = Room.Name;
                        var LstCourse = crsItemOp.Get(Room);//取得教室的所有課程

                        //取得教室目前課程
                        var NowCourse = from c in LstCourse
                                        where c.CourseType_No != "Ch05" && c.ClassDate.Equals(DateTime.Now.Date) &&
                                        c.StartTime <= DateTime.Now && DateTime.Now <= c.EndTime
                                        select c.CourseType_No;


                        //教室目前有課程
                        if (NowCourse.Count() > 0)
                        {
                            //取得教室名稱與目前課程名稱
                            var tmpNowCourse = NowCourse.ToList();
                            var courseName   = crsOp.Get(tmpNowCourse[0]).Name;
                            model.CourseInfo.Add(RoomName + ":" + courseName);
                        }

                        //教室目前沒有課程
                        else
                        {
                            //取得教室名稱 紀錄目前無課程
                            model.CourseInfo.Add(RoomName + ":目前無課程");
                        }
                    }
                    Lstmodel.Add(model);
                }

                return(View(Lstmodel));
            }
            catch (Exception ex)
            {
                TempData["Msg"] = ex.ToString();
                return(View());
            }
        }