| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- using NEducation.Code;
- using NEducation.Models;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Threading;
- using System.Web;
- using System.Web.Mvc;
- using static NEducation.Controllers.UtilsController;
- namespace NEducation.Controllers
- {
- public class HomeFitnessController : BaseController
- {
- private static log4net.ILog log { get; set; } = log4net.LogManager.GetLogger(typeof(HomeFitnessController));
- // GET: HomeFitness
- public ActionResult Index()
- {
- Session["navitab"] = "HomeFitness";
- CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
- HfModel model = new HfModel();
- model.hfDatas = new List<HfData>();
- try
- {
- // get menu
- HfDataRequest request = new HfDataRequest();
- request.parentId = Constant.PARENT_ID;
- String rs = UtilsController.SendPost(request, Session.SessionID, UtilsController.WsType.GetHfDatabyParentId);
- HfDataResponse res = new HfDataResponse(rs);
- if (res.status == Constant.SUCCESS)
- {
- model.hfDatas = res.data;
- Session["categories"] = model.hfDatas;
- }
- return View(model);
- }
- catch (Exception ex)
- {
- log.Error(ex.Message);
- }
- return Redirect("/HomeFitness");
- }
- public ActionResult Menu(String id)
- {
- if (!CheckAuthToken())
- {
- return Redirect("/HomeFitness");
- }
- Session["COURSE_NOW"] = UtilsController.Constant.HOMEFITNESS;
- HfModel model = new HfModel();
- model.hfDatas = new List<HfData>();
- try
- {
- List<HfData> categories = Session["categories"] as List<HfData>;
- if (categories == null || categories.Count == 0)
- {
- return Redirect("/HomeFitness");
- }
- model.hfDataParent = categories.Find(x => x.Id == id);
- if (model.hfDataParent == null)
- {
- return Redirect("/HomeFitness");
- }
- // check register
- // get menu
- HfDataRequest request = new HfDataRequest();
- request.parentId = id;
- String rs = UtilsController.SendPost(request, Session.SessionID, UtilsController.WsType.GetHfDatabyParentId);
- HfDataResponse res = new HfDataResponse(rs);
- if (res.status == Constant.SUCCESS)
- {
- model.hfDatas = res.data;
- Session["menu"] = model.hfDatas;
- }
- return View(model);
- }
- catch (Exception ex)
- {
- log.Error(ex.Message);
- }
- return Redirect("/HomeFitness");
- }
- public ActionResult MenuDetail(String id)
- {
- if (!CheckAuthToken())
- {
- return Redirect("/HomeFitness");
- }
- HfModel model = new HfModel();
- model.hfDatas = new List<HfData>();
- try
- {
- List<HfData> menu = Session["menu"] as List<HfData>;
- if (menu == null || menu.Count == 0)
- {
- return Redirect("/HomeFitness");
- }
- model.hfDataParent = menu.Find(x => x.Id == id);
- if (model.hfDataParent == null)
- {
- return Redirect("/HomeFitness");
- }
- // get menu
- HfDataRequest request = new HfDataRequest();
- request.parentId = id;
- String rs = UtilsController.SendPost(request, Session.SessionID, UtilsController.WsType.GetHfDatabyParentId);
- HfDataResponse res = new HfDataResponse(rs);
- if (res.status == Constant.SUCCESS)
- {
- model.hfDatas = res.data;
- Session["data"] = model.hfDatas;
- }
- return View(model);
- }
- catch (Exception ex)
- {
- log.Error(ex.Message);
- }
- return Redirect("/HomeFitness");
- }
- public ActionResult MenuContent(String id)
- {
- if (!CheckAuthToken())
- {
- return Redirect("/HomeFitness");
- }
- List<SubInfo> subInfo = Session["subInfo"] as List<SubInfo>;
- SubInfo homefitness = null;
- if (subInfo != null)
- {
- homefitness = subInfo.Find(x => x.subServiceName == UtilsController.Constant.EDU_HOME_FITNESS_REG);
- }
- if (homefitness == null)
- {
- return Redirect("/HomeFitness");
- }
- HfModel model = new HfModel();
- model.hfDatas = new List<HfData>();
- try
- {
- //List<HfData> data = Session["data"] as List<HfData>;
- //if (data == null || data.Count == 0)
- //{
- // HfDataRequest request = new HfDataRequest();
- // request.id = id;
- // String rs = UtilsController.SendPost(request, Session.SessionID, UtilsController.WsType.GetHfDatabyId);
- // HfDataResponse res = new HfDataResponse(rs);
- // if (res.status == Constant.SUCCESS)
- // {
- // model.hfDatas = res.data;
- // Session["data"] = model.hfDatas;
- // }
- //}
- //else
- //{
- // model.content = data.Find(x => x.Id == id);
- //}
- HfDataRequest request = new HfDataRequest();
- request.id = id;
- String rs = UtilsController.SendPost(request, Session.SessionID, UtilsController.WsType.GetHfDatabyId);
- HfDataResponse res = new HfDataResponse(rs);
- if (res.status == Constant.SUCCESS)
- {
- if (res.data.Count > 0)
- {
- model.content = res.data[0];
- }
- }
- else
- {
- return Redirect("/HomeFitness");
- }
- return View(model);
- }
- catch (Exception ex)
- {
- log.Error(ex.Message);
- }
- return Redirect("/HomeFitness");
- }
- }
- }
|