Ejemplo n.º 1
0
        public ActionResult RevokeBooking(CalendarEventQueryViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;

            if (viewModel.KeyID != null)
            {
                viewModel.LessonID = viewModel.DecryptKeyValue();
            }

            LessonTime item = models.GetTable <LessonTime>().Where(l => l.LessonID == viewModel.LessonID).FirstOrDefault();

            if (item == null)
            {
                return(Json(new { result = false, message = "課程資料錯誤!!" }));
            }
            else if (item.ContractTrustTrack.Any(t => t.SettlementID.HasValue))
            {
                return(Json(new { result = false, message = "課程資料已信託,不可取消!!" }));
            }
            else if (item.RegisterLesson.IsPaid)
            {
                return(Json(new { result = false, message = "課程資料已收款,不可取消!!" }));
            }
            //else if (item.LessonPlan != null || item.TrainingPlan.Count > 0)
            //{
            //    ViewBag.Message = "請先刪除預編課程!!";
            //    return RedirectToAction("Coach", "Account", new { lessonDate = lessonDate, message= "請先刪除預編課程!!" });
            //}
            item.RevokeBooking(models);

            return(Json(new { result = true }));
        }
Ejemplo n.º 2
0
        public ActionResult RevokeBooking(LessonTimeBookingViewModel viewModel)
        {
            ViewBag.ViewModel = viewModel;

            if (viewModel.KeyID != null)
            {
                viewModel.LessonID = viewModel.DecryptKeyValue();
            }

            LessonTime item = models.GetTable <LessonTime>().Where(l => l.LessonID == viewModel.LessonID).FirstOrDefault();

            if (item == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "課程資料錯誤!!"));
            }
            else if (item.ContractTrustTrack.Any(t => t.SettlementID.HasValue))
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "課程資料已信託,不可取消!!"));
            }
            //else if (item.LessonPlan != null || item.TrainingPlan.Count > 0)
            //{
            //    ViewBag.Message = "請先刪除預編課程!!";
            //    return RedirectToAction("Coach", "Account", new { lessonDate = lessonDate, message= "請先刪除預編課程!!" });
            //}
            item.RevokeBooking(models);

            return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "課程預約已取消!!"));
        }