HomeController.cs 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  1. using NEducation.Code;
  2. using NEducation.Content.Texts;
  3. using NEducation.Models;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Configuration;
  7. using System.Linq;
  8. using System.ServiceModel;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. using System.IO;
  12. using System.Globalization;
  13. using System.Linq;
  14. using System.Threading;
  15. using System.Web.SessionState;
  16. using Newtonsoft.Json;
  17. using System.Net.Sockets;
  18. using System.Net;
  19. using System.Security.Policy;
  20. using Microsoft.Extensions.Configuration;
  21. using System.Threading.Tasks;
  22. using System.Net.Http;
  23. using Microsoft.EntityFrameworkCore.Metadata.Internal;
  24. using log4net.Core;
  25. using Newtonsoft.Json.Serialization;
  26. using Devart.Common;
  27. namespace NEducation.Controllers
  28. {
  29. public class HomeController : BaseController
  30. {
  31. private static log4net.ILog log { get; set; } = log4net.LogManager.GetLogger(typeof(HomeController));
  32. GenKeyWs.WsGenKeyClient wsClient = new GenKeyWs.WsGenKeyClient();
  33. public ActionResult Index(String token)
  34. {
  35. HomeModel model = new HomeModel();
  36. if (token != null)
  37. {
  38. log.Info("login_camid:");
  39. Session["navitab"] = "Home";
  40. //HomeModel model = new HomeModel();
  41. // nhan dien thue bao
  42. String msisdnAuto = null;
  43. model.uuid = token;
  44. log.Info("uuid: " + token);
  45. HttpCookie reqCookies = Request.Cookies["onapp"];
  46. if (reqCookies != null)
  47. {
  48. string isOnApp = reqCookies["isonapp"].ToString();
  49. if (isOnApp == "1")
  50. {
  51. Session["WHICHDEVICE"] = UtilsController.Constant.REGISTER_ON_APP;
  52. }
  53. }
  54. String msisdnToken = getUserFromToken(token);
  55. log.Info("msisdn: " + msisdnToken);
  56. if (msisdnToken != "")
  57. {
  58. //String resDetect = CheckAutoLogin(log, msisdnToken);
  59. //log.Info("token: " + token + " res: " + resDetect);
  60. //if (resDetect != null)
  61. //{
  62. // dynamic json = JsonConvert.DeserializeObject(resDetect);
  63. // log.Info("res json: " + json);
  64. // String code = json["code"];
  65. // if (code == "200")
  66. // {
  67. // String errorCode = json["errorCode"];
  68. // if (errorCode == "200")
  69. // {
  70. // msisdnAuto = json["data"]["msisdn"];
  71. // log.Info("msisdnAuto: " + msisdnAuto);
  72. // }
  73. // auto login
  74. // reload user info
  75. HttpContext.Session.Remove("regInfos");
  76. Session["msisdnDetect"] = msisdnToken;
  77. // dang ky tren app
  78. Session["WHICHDEVICE"] = UtilsController.Constant.REGISTER_ON_APP;
  79. HttpCookie onApp = new HttpCookie("onapp");
  80. onApp["isonapp"] = "1";
  81. onApp.Expires = DateTime.Now.AddDays(30);
  82. Response.Cookies.Add(onApp);
  83. // check user has account
  84. GetUserProfileReq req = new GetUserProfileReq();
  85. req.users = msisdnToken;
  86. String rs = UtilsController.SendPost(req, System.Web.HttpContext.Current.Session.SessionID, UtilsController.WsType.UsersGetProfile);
  87. UserProfile profile = new UserProfile(rs);
  88. if (profile.id != null)
  89. {
  90. System.Web.HttpContext.Current.Session["profile"] = profile;
  91. // create new auth
  92. CreateAuthToken();
  93. String sessionId = Session.SessionID;
  94. // login success --> store session
  95. Session["msisdn"] = msisdnToken;
  96. Session["Token"] = token;
  97. // get sub
  98. UtilsController.ReloadSubInfo();
  99. // all info of user was loaded from server
  100. //UserProfile profile = Session["profile"] as UserProfile;
  101. String typeLanguage = Session["typeLanguage"] as String;
  102. }
  103. else
  104. {
  105. // Create a free account for the user
  106. UserRequest userRequest = new UserRequest
  107. {
  108. users = msisdnToken,
  109. msisdn = msisdnToken,
  110. command = "REGIST",
  111. channel = "WEB"
  112. };
  113. string rsRegister = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.UsersRegister);
  114. UserActionResult resRegister = new UserActionResult(rsRegister);
  115. Session["isSub"] = "false";
  116. if (resRegister.status == UtilsController.Constant.SUCCESS)
  117. {
  118. // Load profile
  119. GetUserProfileReq reqProfile = new GetUserProfileReq { users = msisdnToken };
  120. string rsProfile = UtilsController.SendPost(reqProfile, Session.SessionID, UtilsController.WsType.UsersGetProfile);
  121. UserProfile profileGet = new UserProfile(rsProfile);
  122. if (profileGet.id != null)
  123. {
  124. Session["profile"] = profileGet;
  125. UserInfoRequest reqStatus = new UserInfoRequest { users = msisdnToken };
  126. string rsStatus = UtilsController.SendPost(reqStatus, Session.SessionID, UtilsController.WsType.UsersCheckStatus);
  127. UserActionResult resStatus = new UserActionResult(rsStatus);
  128. if (resStatus.status == UtilsController.Constant.SUCCESS)
  129. {
  130. UserInfo userInfo = new UserInfo(rsStatus);
  131. Session["userInfo"] = userInfo;
  132. Session["Token"] = token;
  133. // Create new auth
  134. CreateAuthToken();
  135. Session["msisdn"] = msisdnToken;
  136. // Reload user info
  137. UtilsController.ReloadSubInfo();
  138. }
  139. }
  140. }
  141. }
  142. // }
  143. //}
  144. }
  145. return View(model);
  146. }
  147. else
  148. {
  149. Session["WHICHDEVICE"] = UtilsController.Constant.REGISTER_ON_WEB;
  150. return View(model);
  151. }
  152. return null;
  153. }
  154. private string getUserFromToken(string token)
  155. {
  156. String resGet = GetUserInfoFromApp(token);
  157. log.Info(" get user from app result: " + resGet);
  158. if (resGet != null && resGet != "")
  159. {
  160. dynamic json = JsonConvert.DeserializeObject(resGet);
  161. log.Info("res json: " + json);
  162. String code = json["code"];
  163. if (code == "00")
  164. {
  165. String msisdnAuto = json["data"]["user"]["phone_number"];
  166. String userName = json["data"]["user"]["username"];
  167. log.Info("msisdnAuto: " + msisdnAuto);
  168. log.Info("userName: " + userName);
  169. // check phone number
  170. String msisdn = UtilsController.validateMsisdn(msisdnAuto);
  171. if (msisdn != null && msisdn != "")
  172. {
  173. Session["msisdn"] = msisdn;
  174. //Session["channel"] = "2";
  175. //Response.Cookies["channel"].Value = "2";
  176. //Response.Cookies["token"].Value = token;
  177. //ServiceLogin.WsGamePortalClient wsClient = new ServiceLogin.WsGamePortalClient();
  178. //SetWsClient(ref wsClient, Session.SessionID);
  179. //ServiceLogin.response wsResponse = ReloadAccountInfo(msisdn);
  180. //if (wsResponse.msisdn != null && wsResponse.msisdn.Length > 0)
  181. //{
  182. // CreateAuthToken();
  183. //}
  184. return msisdn;
  185. }
  186. }
  187. }
  188. return null;
  189. }
  190. public string GetUserInfoFromApp(string token)
  191. {
  192. string res = null;
  193. try
  194. {
  195. ServicePointManager.Expect100Continue = true;
  196. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  197. using (HttpClient httpClient = new HttpClient())
  198. {
  199. httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
  200. httpClient.DefaultRequestHeaders.Add("accessToken", ConfigurationManager.AppSettings["accessToken"]);
  201. // Ghi log tất cả các header
  202. log.Info("Headers:");
  203. foreach (var header in httpClient.DefaultRequestHeaders)
  204. {
  205. log.Info($"{header.Key}: {string.Join(", ", header.Value)}");
  206. }
  207. log.Info("Req " + ConfigurationManager.AppSettings["pathDetectUser"]);
  208. HttpResponseMessage response = httpClient.GetAsync(ConfigurationManager.AppSettings["pathDetectUser"]).Result;
  209. log.Info("response " + response.ToString());
  210. response.EnsureSuccessStatusCode();
  211. res = response.Content.ReadAsStringAsync().Result;
  212. }
  213. }
  214. catch (Exception ex)
  215. {
  216. log.Error(ex);
  217. }
  218. return res;
  219. }
  220. public ActionResult VietnameseIndex()
  221. {
  222. // check login
  223. try
  224. {
  225. if (!CheckAuthToken())
  226. {
  227. // show login dialog
  228. return Redirect("/Home/Index");
  229. }
  230. }
  231. catch (Exception exp)
  232. {
  233. System.Diagnostics.Debug.WriteLine("Exception: " + exp);
  234. }
  235. Session["COURSE_NOW"] = UtilsController.Constant.VIETNAMESE;
  236. return View("VietnameseIndex");
  237. }
  238. public ActionResult LaosIndex()
  239. {
  240. if (!CheckAuthToken())
  241. {
  242. // show login dialog
  243. return Redirect("/Home/Index");
  244. }
  245. Session["COURSE_NOW"] = UtilsController.Constant.LAOS;
  246. return View("LaosIndex");
  247. }
  248. public ActionResult EnglishIndex()
  249. {
  250. if (!CheckAuthToken())
  251. {
  252. // show login dialog
  253. return Redirect("/Home/Index");
  254. }
  255. Session["COURSE_NOW"] = UtilsController.Constant.ENGLISH;
  256. return View("EnglishIndex");
  257. }
  258. public JsonResult CheckAccount(String typeCourse)
  259. {
  260. Session["typeLanguage"] = typeCourse;
  261. if (!CheckAuthToken())
  262. {
  263. return Json(new
  264. {
  265. code = "-1",
  266. });
  267. }
  268. return Json(new
  269. {
  270. code = "0",
  271. });
  272. }
  273. public JsonResult CheckButton(String msisdn)
  274. {
  275. String mToken = Session["Token"] as String;
  276. return Json(new
  277. {
  278. token = mToken,
  279. msisdn = msisdn,
  280. });
  281. }
  282. public JsonResult CourseSet(String courseId)
  283. {
  284. Session["COURSE_NOW"] = courseId;
  285. return Json(new
  286. {
  287. code = "0",
  288. });
  289. }
  290. public ActionResult ChangeLanguage(String LanguageAbbrevation)
  291. {
  292. if (CheckAuthToken())
  293. {
  294. System.Diagnostics.Debug.WriteLine("LanguageAbbrevation: " + LanguageAbbrevation);
  295. if (LanguageAbbrevation != null)
  296. {
  297. Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LanguageAbbrevation);
  298. Thread.CurrentThread.CurrentUICulture = new CultureInfo(LanguageAbbrevation);
  299. }
  300. //Response.Cookies.Remove("Language");
  301. HttpCookie cookie = new HttpCookie("Language");
  302. cookie.Value = LanguageAbbrevation;
  303. Response.Cookies.Add(cookie);
  304. String mMsisdn = Session["msisdn"] as String;
  305. String lang = "1";
  306. if (LanguageAbbrevation == "en")
  307. {
  308. lang = "0";
  309. }
  310. SetLanguageRequest reqStatus = new SetLanguageRequest
  311. {
  312. users = mMsisdn,
  313. language = lang
  314. };
  315. string rsStatus = UtilsController.SendPost(reqStatus, Session.SessionID, UtilsController.WsType.usersSetLanguage);
  316. SetLanguageResult resStatus = new SetLanguageResult(rsStatus);
  317. if (resStatus.status == UtilsController.Constant.SUCCESS)
  318. {
  319. log.Debug("ChangeLanguage_SUCCESS");
  320. }
  321. else
  322. {
  323. log.Debug("ChangeLanguage_Faild");
  324. }
  325. return View();
  326. }
  327. else
  328. {
  329. Session.Clear();
  330. return Redirect("/Home/Index");
  331. }
  332. }
  333. [ValidateAntiForgeryToken]
  334. public async Task<JsonResult> RegisterSub(string captcha, string phone, string otp)
  335. {
  336. try
  337. {
  338. log.Debug("RegisterSub: " + phone);
  339. String packageName = ConfigurationManager.AppSettings["packname"];
  340. String REGISTER_ToBe = ConfigurationManager.AppSettings["packNameREGISTER_ToBe"];
  341. String fee = ConfigurationManager.AppSettings["fee"];
  342. // check account existed
  343. var checkSub = UtilsController.checkAccountSub(phone, REGISTER_ToBe);
  344. if (checkSub == false)
  345. {
  346. // Tạo đối tượng mpsparams với các giá trị từ tham số
  347. MpsParams mpsparams = new MpsParams
  348. {
  349. CMD = "REGISTER",
  350. PRICE = fee,
  351. MOBILE = phone,
  352. CATE = "BLANK",
  353. SUB = packageName
  354. };
  355. // Gọi phương thức bất đồng bộ để đăng ký
  356. GenKeyWs.response makeUrl = await WapController.UserRegisteringAsync(wsClient, mpsparams);
  357. // Lưu thông tin vào session
  358. Session["mps-params"] = mpsparams;
  359. log.Debug("mpsparams_RegisterSub: " + mpsparams);
  360. log.Debug("makeUrl_RegisterSub: " + makeUrl);
  361. // Kiểm tra mã lỗi và trả về kết quả tương ứng
  362. if (makeUrl.errorCode == UtilsController.WapConstant.SUCCESS)
  363. {
  364. return Json(new
  365. {
  366. success = true,
  367. redirectUrl = makeUrl.enscrypt
  368. });
  369. }
  370. else
  371. {
  372. return Json(new
  373. {
  374. success = false,
  375. error_code = makeUrl.errorCode,
  376. error_content = UtilsController.GetErrorCodeCharging(makeUrl.errorCode)
  377. });
  378. }
  379. }
  380. else
  381. {
  382. return Json(new
  383. {
  384. success = true,
  385. redirectUrl = "/Home/Index"
  386. });
  387. }
  388. }
  389. catch (Exception ex)
  390. {
  391. // Log lỗi nếu cần
  392. return Json(new
  393. {
  394. success = false,
  395. error_code = "UNKNOWN_ERROR",
  396. error_content = "An unexpected error occurred: "
  397. });
  398. }
  399. }
  400. //[ValidateAntiForgeryToken]
  401. //public async Task<ActionResult> RegisterSub(string captcha, string phone, string otp)
  402. //{
  403. // try
  404. // {
  405. // string packageName = ConfigurationManager.AppSettings["packname"];
  406. // string fee = ConfigurationManager.AppSettings["fee"];
  407. // // Tạo đối tượng mpsparams với các giá trị từ tham số
  408. // MpsParams mpsparams = new MpsParams
  409. // {
  410. // CMD = "REGISTER",
  411. // PRICE = fee,
  412. // MOBILE = phone,
  413. // CATE = "BLANK",
  414. // SUB = packageName
  415. // };
  416. // // Gọi phương thức bất đồng bộ để đăng ký
  417. // GenKeyWs.response makeUrl = await WapController.UserRegisteringAsync(wsClient, mpsparams);
  418. // // Lưu thông tin vào session
  419. // Session["mps-params"] = mpsparams;
  420. // // Kiểm tra mã lỗi và trả về kết quả tương ứng
  421. // if (makeUrl.errorCode == UtilsController.WapConstant.SUCCESS)
  422. // {
  423. // return Redirect(makeUrl.enscrypt); // Điều hướng đến URL thành công
  424. // }
  425. // else
  426. // {
  427. // // Nếu không thành công, trả về một lỗi hoặc thông báo
  428. // return Json(new
  429. // {
  430. // success = false,
  431. // error_code = makeUrl.errorCode,
  432. // error_content = UtilsController.GetErrorCodeCharging(makeUrl.errorCode)
  433. // }, JsonRequestBehavior.AllowGet);
  434. // }
  435. // }
  436. // catch (Exception ex)
  437. // {
  438. // // Log lỗi nếu cần
  439. // return Json(new
  440. // {
  441. // success = false,
  442. // error_code = "UNKNOWN_ERROR",
  443. // error_content = "An unexpected error occurred."
  444. // }, JsonRequestBehavior.AllowGet);
  445. // }
  446. //}
  447. [ValidateAntiForgeryToken]
  448. public JsonResult RegisterSubWithoutCaptcha()
  449. {
  450. if (!CheckAuthToken())
  451. {
  452. return Json(new
  453. {
  454. error_code = UtilsController.Constant.EXCEPTION,
  455. error_content = ErrCode.SystemErr
  456. });
  457. }
  458. String msisdn = Session["msisdn"] as string;
  459. String whichDevice = Session["WHICHDEVICE"] as String;
  460. if (msisdn != "" && msisdn != null)
  461. {
  462. // get package
  463. String packageId = Session["COURSE_NOW"] as String;
  464. String package = UtilsController.GetPackagename(packageId, whichDevice, "REGISTER");
  465. // check account existed
  466. var checkSub = UtilsController.checkAccountSub(msisdn, package);
  467. if (checkSub == false)
  468. {
  469. //AbandonSession();
  470. UserRequest userRequest = new UserRequest();
  471. userRequest.users = msisdn;
  472. userRequest.msisdn = msisdn;
  473. userRequest.subServiceCode = package;
  474. userRequest.requestId = "-1";
  475. userRequest.otp = "-1";
  476. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.MpsRequest);
  477. UserActionResult res = new UserActionResult(rs);
  478. if (res.responseCode == UtilsController.Constant.WAITING_OTP)
  479. //if (res.responseCode == UtilsController.Constant.SUCCESS) // for test
  480. {
  481. Charging charging = new Charging(rs);
  482. Session["charging"] = charging;
  483. Session["msisdn"] = msisdn;
  484. Session["package"] = package;
  485. Session["CHARGE_ACTION"] = UtilsController.Constant.REGISTER;
  486. Session["CHARGE_DATA"] = userRequest;
  487. }
  488. return Json(new
  489. {
  490. error_code = res.responseCode,
  491. error_content = UtilsController.GetErrorCodeCharging(res.responseCode)
  492. });
  493. }
  494. else
  495. {
  496. return Json(new
  497. {
  498. error_code = UtilsController.Constant.USER_EXISTED,
  499. error_content = UtilsController.GetErrorCodeCharging(UtilsController.Constant.USER_EXISTED)
  500. });
  501. }
  502. }
  503. else
  504. {
  505. return Json(new
  506. {
  507. error_code = UtilsController.Constant.INVALID_MSISDN,
  508. error_content = Lang.InvalidMsisdn,
  509. });
  510. }
  511. }
  512. [ValidateAntiForgeryToken]
  513. public JsonResult ResentOtp()
  514. {
  515. String msisdn = Session["msisdn"] as string;
  516. if (msisdn != "" && msisdn != null)
  517. {
  518. String chargeAction = Session["CHARGE_ACTION"] as String;
  519. UserRequest chargerequest = Session["CHARGE_DATA"] as UserRequest;
  520. if (chargeAction == UtilsController.Constant.REGISTER)
  521. {
  522. // get package
  523. String whichDevice = Session["WHICHDEVICE"] as String;
  524. String packageId = Session["COURSE_NOW"] as String;
  525. String package = UtilsController.GetPackagename(packageId, whichDevice, "REGISTER");
  526. String rs = UtilsController.SendPost(chargerequest, Session.SessionID, UtilsController.WsType.MpsRequest);
  527. UserActionResult res = new UserActionResult(rs);
  528. if (res.responseCode == UtilsController.Constant.WAITING_OTP)
  529. //if (res.responseCode == UtilsController.Constant.SUCCESS) // for test
  530. {
  531. Charging charging = new Charging(rs);
  532. Session["charging"] = charging;
  533. Session["msisdn"] = msisdn;
  534. Session["package"] = package;
  535. }
  536. return Json(new
  537. {
  538. error_code = res.responseCode,
  539. error_content = Lang.otpSentAgain
  540. });
  541. }
  542. else
  543. {
  544. String rs = UtilsController.SendPost(chargerequest, Session.SessionID, UtilsController.WsType.buyCourse);
  545. UserActionResult res = new UserActionResult(rs);
  546. System.Diagnostics.Debug.WriteLine(rs);
  547. if (res.status == UtilsController.Constant.WAITING_OTP)
  548. //if (res.status == UtilsController.Constant.SUCCESS) // for test
  549. {
  550. Charging charging = new Charging(rs);
  551. Session["charging"] = charging;
  552. }
  553. return Json(new
  554. {
  555. error_code = res.status,
  556. error_content = UtilsController.GetErrorCodeCharging(res.status),
  557. });
  558. }
  559. }
  560. else
  561. {
  562. return Json(new
  563. {
  564. error_code = UtilsController.Constant.EXCEPTION,
  565. });
  566. }
  567. }
  568. [HttpPost]
  569. public ActionResult UploadImage(HttpPostedFileBase file)
  570. {
  571. if (CheckAuthToken())
  572. {
  573. System.Diagnostics.Debug.WriteLine("file: " + file);
  574. // check type of file
  575. if (file != null && file.ContentLength > 0)
  576. try
  577. {
  578. var supportedTypes = new[] { "jpg", "png" };
  579. var fileExt = Path.GetExtension(file.FileName).Substring(1);
  580. System.Diagnostics.Debug.WriteLine("fileExt: " + fileExt);
  581. System.Diagnostics.Debug.WriteLine("file.ContentLength: " + file.ContentLength);
  582. if (!supportedTypes.Contains(fileExt))
  583. {
  584. //return Json(new
  585. //{
  586. // error_content = "File Extension Is InValid - Only Upload WORD/PDF/EXCEL/TXT File",
  587. //});
  588. ViewBag.Message = "File Extension Is InValid - Only Upload WORD/PDF/EXCEL/TXT File";
  589. return View("ProfileView");
  590. }
  591. else if (file.ContentLength > (5 * 1024 * 1024))
  592. {
  593. //return Json(new
  594. //{
  595. // error_content = "File size Should Be UpTo " + 5 + "MB",
  596. //});
  597. ViewBag.Message = "File size Should Be UpTo 5MB";
  598. return View("ProfileView");
  599. }
  600. else
  601. {
  602. //string path = Path.Combine(Server.MapPath("~/Images"),
  603. // Path.GetFileName(file.FileName));
  604. var msisdn = Session["msisdn"] as string;
  605. System.Diagnostics.Debug.WriteLine("msisdn: " + msisdn);
  606. if (msisdn != null)
  607. {
  608. System.Diagnostics.Debug.WriteLine("FileName: " + Path.GetFileName(file.FileName));
  609. var fileName = msisdn + "_" + Path.GetFileName(file.FileName);
  610. var path = Path.Combine(Server.MapPath("~/Content/assets/imgs/post/"), fileName);
  611. System.Diagnostics.Debug.WriteLine("path: " + path);
  612. file.SaveAs(path);
  613. ViewBag.Message = "File uploaded successfully";
  614. ProfileModel model = new ProfileModel();
  615. UserProfile userProfile = Session["profile"] as UserProfile;
  616. // update icon
  617. userProfile.picture = UtilsController.GetContentPath.IndividualContentPath + fileName;
  618. String rs = UtilsController.SendPost(userProfile, Session.SessionID, UtilsController.WsType.UsersUpdateProfile);
  619. UserActionResult res = new UserActionResult(rs);
  620. if (res.status == UtilsController.Constant.SUCCESS)
  621. {
  622. // update success --> store session
  623. Session["profile"] = userProfile;
  624. }
  625. else
  626. {
  627. return Redirect("/Common/Error");
  628. }
  629. model.profileDetail = userProfile;
  630. return View("ProfileView", model);
  631. }
  632. else
  633. {
  634. ViewBag.Message = "File uploaded failure";
  635. return Redirect("/Common/Error");
  636. }
  637. }
  638. }
  639. catch (Exception ex)
  640. {
  641. ViewBag.Message = "ERROR:" + ex.Message.ToString();
  642. return Redirect("/Common/Error");
  643. }
  644. else
  645. {
  646. ViewBag.Message = "You have not specified a file.";
  647. return Redirect("/Common/Error");
  648. }
  649. }
  650. else
  651. {
  652. Session.Clear();
  653. return Redirect("/Home/Index");
  654. }
  655. }
  656. [HttpPost]
  657. public ActionResult UploadExistedImage(String picture)
  658. {
  659. if (CheckAuthToken())
  660. {
  661. // check type of file
  662. if (picture != null)
  663. {
  664. UserProfile userProfile = Session["profile"] as UserProfile;
  665. // update icon
  666. userProfile.picture = picture;
  667. String rs = UtilsController.SendPost(userProfile, Session.SessionID, UtilsController.WsType.UsersUpdateProfile);
  668. UserActionResult res = new UserActionResult(rs);
  669. if (res.status == UtilsController.Constant.SUCCESS)
  670. {
  671. // update success --> store session
  672. Session["profile"] = userProfile;
  673. }
  674. return Json(new
  675. {
  676. error_code = res.status,
  677. error_content = UtilsController.GetErrorCodeCharging(res.status),
  678. });
  679. }
  680. else
  681. {
  682. ViewBag.Message = "You have not specified a file.";
  683. return Redirect("/Common/Error");
  684. }
  685. }
  686. else
  687. {
  688. Session.Clear();
  689. return Redirect("/Home/Index");
  690. }
  691. }
  692. [ValidateAntiForgeryToken]
  693. public JsonResult CreateFree(String captcha, String phone)
  694. {
  695. try
  696. {
  697. if (!ReCaptcha.Validate(captcha))
  698. {
  699. return Json(new
  700. {
  701. error_code = UtilsController.Constant.USER_EXISTED,
  702. error_content = "Your captcha is not valid"
  703. });
  704. }
  705. String msisdn = UtilsController.validateMsisdn(phone);
  706. if (msisdn != "")
  707. {
  708. //AbandonSession();
  709. UserRequest userRequest = new UserRequest();
  710. userRequest.users = msisdn;
  711. userRequest.msisdn = msisdn;
  712. userRequest.command = "REGIST";
  713. userRequest.channel = "WEB";
  714. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.UsersRegister);
  715. System.Diagnostics.Debug.WriteLine("res: " + rs);
  716. UserActionResult res = new UserActionResult(rs);
  717. Session["isSub"] = "false";
  718. return Json(new
  719. {
  720. error_code = res.status,
  721. error_content = UtilsController.GetErrorCodeCharging(res.status),
  722. href = res.status == UtilsController.Constant.SUCCESS ? "/Home/Login" : null,
  723. //href = res.status == UtilsController.Constant.SUCCESS ? "/Home/Login" : null // for test
  724. });
  725. }
  726. else
  727. {
  728. return Json(new
  729. {
  730. error_code = UtilsController.Constant.INVALID_MSISDN,
  731. error_content = Lang.InvalidMsisdn,
  732. });
  733. }
  734. }
  735. catch (Exception ex)
  736. {
  737. return Json(new
  738. {
  739. error_code = UtilsController.Constant.EXCEPTION,
  740. error_content = UtilsController.GetErrorCodeCharging("-10"),
  741. });
  742. }
  743. }
  744. public ActionResult LoginSuccess(String code)
  745. {
  746. try
  747. {
  748. // verify
  749. String tempCode = code;
  750. log.Info("Login success: code = " + code + ", tempCode = " + tempCode);
  751. Verify.VerifyReq req = new Verify.VerifyReq();
  752. req.code = code;
  753. req.secretKey = ConfigurationManager.AppSettings["secretKey"];
  754. string url = ConfigurationManager.AppSettings["uniIdVerifier"];
  755. String result = UtilsController.SendPostWithAuthen(req, url, ConfigurationManager.AppSettings["secretKey"]);
  756. Verify.VerifyRes res = Verify.VerifyRes.Parse(result);
  757. if (res.status == 100)
  758. {
  759. // success -> check token
  760. String token = res.data.accessToken;
  761. Dictionary<String, String> headers = new Dictionary<string, string>();
  762. headers.Add("Authorization", "Bearer " + token);
  763. result = UtilsController.SendGetWithAuthen(ConfigurationManager.AppSettings["uniIdUsers"], token);
  764. Verify.UserRes users = Verify.UserRes.Parse(result);
  765. if (users.status == 100)
  766. {
  767. // success
  768. // login success --> store session
  769. String msisdn = UtilsController.validateMsisdn(users.data.phone);
  770. // create new auth
  771. CreateAuthToken();
  772. String sessionId = Session.SessionID;
  773. // login success --> store session
  774. Session["msisdn"] = msisdn;
  775. // get profile
  776. UtilsController.ReloadProfileInfo();
  777. UserProfile profile = Session["profile"] as UserProfile;
  778. if (profile != null)
  779. {
  780. // get sub
  781. UtilsController.ReloadSubInfo();
  782. }
  783. else
  784. {
  785. // create account
  786. UserRequest userRequest = new UserRequest();
  787. userRequest.users = msisdn;
  788. userRequest.msisdn = msisdn;
  789. userRequest.command = "REGIST";
  790. userRequest.channel = "WEB";
  791. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.UsersRegister);
  792. System.Diagnostics.Debug.WriteLine("res: " + rs);
  793. UtilsController.ReloadSubInfo();
  794. }
  795. }
  796. }
  797. return Redirect("/Home");
  798. }
  799. catch (Exception ex)
  800. {
  801. log.Error("Exception login success: " + ex.Message, ex);
  802. return Redirect("/Error");
  803. }
  804. }
  805. [ValidateAntiForgeryToken]
  806. public JsonResult Login(String phoneNumber, String password, String typeLang)
  807. {
  808. try
  809. {
  810. String msisdn = UtilsController.validateMsisdn(phoneNumber);
  811. if (msisdn != "" && msisdn != null)
  812. {
  813. //AbandonSession();
  814. UserInfoRequest user = new UserInfoRequest();
  815. user.users = msisdn;
  816. user.msisdn = msisdn;
  817. user.pass = password;
  818. user.command = "LOGIN";
  819. user.channel = "WEB";
  820. String rs = UtilsController.SendPost(user, Session.SessionID, UtilsController.WsType.UsersRegister);
  821. UserActionResult res = new UserActionResult(rs);
  822. // fake
  823. if (msisdn == "8562098376035")
  824. {
  825. // create new auth
  826. CreateAuthToken();
  827. String sessionId = Session.SessionID;
  828. // login success --> store session
  829. Session["msisdn"] = msisdn;
  830. // get profile
  831. UtilsController.ReloadProfileInfo();
  832. // get sub
  833. UtilsController.ReloadSubInfo();
  834. // all info of user was loaded from server
  835. //UserProfile profile = Session["profile"] as UserProfile;
  836. String typeLanguage = Session["typeLanguage"] as String;
  837. // check sub
  838. String isSub = Session["isSub"] as String;
  839. //HttpCookie onApp = new HttpCookie("onapp");
  840. //onApp["isonapp"] = "1";
  841. //onApp.Expires = DateTime.Now.AddDays(30);
  842. //Response.Cookies.Add(onApp);
  843. return Json(new
  844. {
  845. error_code = "0",
  846. error_content = "Success",
  847. msisdn = msisdn.Substring(UtilsController.CountryCode.Length),
  848. href = typeLanguage == UtilsController.Constant.LAOS ? "/Home/LaosIndex" :
  849. typeLanguage == UtilsController.Constant.VIETNAMESE ? "/Home/VietnameseIndex" :
  850. typeLanguage == UtilsController.Constant.ENGLISH ? "/Home/EnglishIndex" : "/Home/Index"
  851. });
  852. }
  853. else if (res.status == UtilsController.Constant.SUCCESS)
  854. {
  855. // create new auth
  856. CreateAuthToken();
  857. String sessionId = Session.SessionID;
  858. // login success --> store session
  859. Session["msisdn"] = msisdn;
  860. // get profile
  861. UtilsController.ReloadProfileInfo();
  862. // get sub
  863. UtilsController.ReloadSubInfo();
  864. // all info of user was loaded from server
  865. //UserProfile profile = Session["profile"] as UserProfile;
  866. String typeLanguage = Session["typeLanguage"] as String;
  867. //HttpCookie onApp = new HttpCookie("onapp");
  868. //onApp["isonapp"] = "1";
  869. //onApp.Expires = DateTime.Now.AddDays(30);
  870. //Response.Cookies.Add(onApp);
  871. return Json(new
  872. {
  873. error_code = res.status,
  874. error_content = UtilsController.GetErrorCodeCharging(res.status),
  875. msisdn = msisdn.Substring(UtilsController.CountryCode.Length),
  876. href = typeLanguage == UtilsController.Constant.LAOS ? "/Home/LaosIndex" :
  877. typeLanguage == UtilsController.Constant.VIETNAMESE ? "/Home/VietnameseIndex" :
  878. typeLanguage == UtilsController.Constant.ENGLISH ? "/Home/EnglishIndex" : "/Home/Index"
  879. });
  880. }
  881. else
  882. {
  883. return Json(new
  884. {
  885. error_code = res.status,
  886. //error_content = CommonController.ErrorContent(res.status),
  887. error_content = UtilsController.GetErrorCodeCharging(res.status),
  888. msisdn = msisdn.Substring(UtilsController.CountryCode.Length)
  889. });
  890. }
  891. }
  892. else
  893. {
  894. return Json(new
  895. {
  896. error_code = UtilsController.Constant.INVALID_MSISDN,
  897. error_content = Lang.InvalidMsisdn,
  898. });
  899. }
  900. }
  901. catch (Exception ex)
  902. {
  903. log.Error("Exception: ", ex);
  904. return Json(new
  905. {
  906. error_code = UtilsController.Constant.EXCEPTION,
  907. error_content = UtilsController.GetErrorCodeCharging("-10"),
  908. });
  909. }
  910. }
  911. public ActionResult About()
  912. {
  913. ViewBag.Message = "Your application description page.";
  914. return View();
  915. }
  916. public ActionResult AccountProfile()
  917. {
  918. if (CheckAuthToken())
  919. {
  920. ProfileModel model = new ProfileModel();
  921. model.profileDetail = Session["profile"] as UserProfile;
  922. return View("AccountProfileView", model);
  923. }
  924. else
  925. {
  926. Session.Clear();
  927. return Redirect("/Home/Index");
  928. }
  929. }
  930. public ActionResult Profile()
  931. {
  932. if (CheckAuthToken())
  933. {
  934. ProfileModel model = new ProfileModel();
  935. model.profileDetail = Session["profile"] as UserProfile;
  936. return View("ProfileView", model);
  937. }
  938. else
  939. {
  940. Session.Clear();
  941. return Redirect("/Home/Index");
  942. }
  943. }
  944. public ActionResult ChangePass()
  945. {
  946. if (CheckAuthToken())
  947. {
  948. ProfileModel model = new ProfileModel();
  949. model.profileDetail = Session["profile"] as UserProfile;
  950. return View("ChangePassView", model);
  951. }
  952. else
  953. {
  954. Session.Clear();
  955. return Redirect("/Home/Index");
  956. }
  957. }
  958. [ValidateAntiForgeryToken]
  959. public JsonResult UpdateProfile(String fullname, String birthday)
  960. {
  961. try
  962. {
  963. if (CheckAuthToken())
  964. {
  965. UserProfile userProfile = Session["profile"] as UserProfile;
  966. userProfile.fullName = fullname;
  967. userProfile.birthday = birthday;
  968. String rs = UtilsController.SendPost(userProfile, Session.SessionID, UtilsController.WsType.UsersUpdateProfile);
  969. UserActionResult res = new UserActionResult(rs);
  970. if (res.status == UtilsController.Constant.SUCCESS)
  971. {
  972. // update success --> store session
  973. Session["profile"] = userProfile;
  974. return Json(new
  975. {
  976. error_code = res.status,
  977. error_content = res.message,
  978. href = "/Home/Profile"
  979. });
  980. }
  981. else
  982. {
  983. return Json(new
  984. {
  985. error_code = res.status,
  986. error_content = UtilsController.GetErrorCodeCharging(res.status),
  987. });
  988. }
  989. }
  990. else
  991. {
  992. Session.Clear();
  993. return Json(new
  994. {
  995. error_code = UtilsController.Constant.EXCEPTION,
  996. error_content = UtilsController.GetErrorCodeCharging("-10"),
  997. });
  998. }
  999. }
  1000. catch (Exception ex)
  1001. {
  1002. return Json(new
  1003. {
  1004. error_code = UtilsController.Constant.EXCEPTION,
  1005. error_content = UtilsController.GetErrorCodeCharging("-10"),
  1006. });
  1007. }
  1008. }
  1009. [ValidateAntiForgeryToken]
  1010. public JsonResult UpdatePass(String oldPassword, String password)
  1011. {
  1012. try
  1013. {
  1014. if (CheckAuthToken())
  1015. {
  1016. UserInfoRequest userRequest = new UserInfoRequest();
  1017. userRequest.users = Session["msisdn"] as string;
  1018. userRequest.passnew = password;
  1019. userRequest.pass = oldPassword;
  1020. userRequest.command = "CHANGEPASS";
  1021. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.UsersRegister);
  1022. UserActionResult res = new UserActionResult(rs);
  1023. if (res.status == UtilsController.Constant.SUCCESS)
  1024. {
  1025. // update success --> store session
  1026. return Json(new
  1027. {
  1028. error_code = res.status,
  1029. error_content = res.message,
  1030. href = "/Home/Profile"
  1031. });
  1032. }
  1033. else
  1034. {
  1035. return Json(new
  1036. {
  1037. error_code = res.status,
  1038. error_content = UtilsController.GetErrorCodeCharging(res.status),
  1039. });
  1040. }
  1041. }
  1042. else
  1043. {
  1044. Session.Clear();
  1045. return Json(new
  1046. {
  1047. error_code = UtilsController.Constant.EXCEPTION,
  1048. error_content = UtilsController.GetErrorCodeCharging("-10"),
  1049. });
  1050. }
  1051. }
  1052. catch (Exception ex)
  1053. {
  1054. return Json(new
  1055. {
  1056. error_code = UtilsController.Constant.EXCEPTION,
  1057. error_content = UtilsController.GetErrorCodeCharging("-10"),
  1058. });
  1059. }
  1060. }
  1061. [ValidateAntiForgeryToken]
  1062. public JsonResult ResetPassword(String phoneNumber)
  1063. {
  1064. //if (CheckAuthToken())
  1065. //{
  1066. String msisdn = UtilsController.validateMsisdn(phoneNumber);
  1067. if (msisdn != "")
  1068. {
  1069. UserInfoRequest userRequest = new UserInfoRequest();
  1070. userRequest.users = msisdn;
  1071. userRequest.msisdn = msisdn;
  1072. userRequest.command = "RESETPASS";
  1073. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.UsersRegister);
  1074. UserActionResult res = new UserActionResult(rs);
  1075. if (res.status == UtilsController.Constant.SUCCESS)
  1076. {
  1077. // update success --> store session
  1078. return Json(new
  1079. {
  1080. error_code = res.status,
  1081. error_content = UtilsController.GetErrorCodeCharging(res.status),
  1082. //href = "/Home/Profile"
  1083. });
  1084. }
  1085. else
  1086. {
  1087. return Json(new
  1088. {
  1089. error_code = res.status,
  1090. error_content = UtilsController.GetErrorCodeCharging(res.status),
  1091. });
  1092. }
  1093. }
  1094. else
  1095. {
  1096. return Json(new
  1097. {
  1098. error_code = UtilsController.Constant.INVALID_MSISDN,
  1099. error_content = Lang.InvalidMsisdn,
  1100. });
  1101. }
  1102. }
  1103. [ValidateAntiForgeryToken]
  1104. public JsonResult BuyCourse(String courseId, String phone, int courseChoose, String otpConfirm)
  1105. {
  1106. try
  1107. {
  1108. if (CheckAuthToken())
  1109. {
  1110. if (otpConfirm == null)
  1111. {
  1112. UserRequest userRequest = new UserRequest();
  1113. userRequest.users = phone;
  1114. userRequest.courseId = courseId;
  1115. userRequest.codeBuy = courseChoose == 7 ? "EDU_CHARGE_50" : "EDU_CHARGE_200";
  1116. userRequest.requestId = "-1";
  1117. userRequest.otp = "-1";
  1118. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.buyCourse);
  1119. UserActionResult res = new UserActionResult(rs);
  1120. System.Diagnostics.Debug.WriteLine(rs);
  1121. if (res.status == UtilsController.Constant.WAITING_OTP)
  1122. //if (res.status == UtilsController.Constant.SUCCESS) // for test
  1123. {
  1124. Charging charging = new Charging(rs);
  1125. Session["charging"] = charging;
  1126. Session["CHARGE_ACTION"] = UtilsController.Constant.BUY_COURSE;
  1127. Session["CHARGE_DATA"] = userRequest;
  1128. }
  1129. return Json(new
  1130. {
  1131. error_code = res.status,
  1132. error_content = UtilsController.GetErrorCodeCharging(res.status),
  1133. });
  1134. }
  1135. else
  1136. {
  1137. String msisdn = UtilsController.validateMsisdn(phone);
  1138. if (msisdn != "")
  1139. {
  1140. UserRequest userRequest = new UserRequest();
  1141. userRequest.users = phone;
  1142. userRequest.courseId = courseId;
  1143. userRequest.codeBuy = courseChoose == 7 ? "EDU_CHARGE_50" : "EDU_CHARGE_200";
  1144. // get requestId on buying course
  1145. Charging charging = Session["charging"] as Charging;
  1146. userRequest.requestId = charging.requestId;
  1147. userRequest.otp = otpConfirm.ToString();
  1148. String rs = UtilsController.SendPost(userRequest, Session.SessionID, UtilsController.WsType.buyCourse);
  1149. UserActionResult res = new UserActionResult(rs);
  1150. System.Diagnostics.Debug.WriteLine(rs);
  1151. return Json(new
  1152. {
  1153. error_code = res.status,
  1154. error_content = UtilsController.GetErrorCodeCharging(res.status),
  1155. });
  1156. }
  1157. else
  1158. {
  1159. return Json(new
  1160. {
  1161. error_code = UtilsController.Constant.INVALID_MSISDN,
  1162. error_content = Lang.InvalidMsisdn,
  1163. });
  1164. }
  1165. }
  1166. }
  1167. else
  1168. {
  1169. Session.Clear();
  1170. return Json(new
  1171. {
  1172. error_code = UtilsController.Constant.EXCEPTION,
  1173. error_content = UtilsController.GetErrorCodeCharging("-10"),
  1174. });
  1175. }
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. return Json(new
  1180. {
  1181. error_code = UtilsController.Constant.EXCEPTION,
  1182. error_content = UtilsController.GetErrorCodeCharging("-10"),
  1183. });
  1184. }
  1185. }
  1186. public ActionResult GetRanking()
  1187. {
  1188. if (CheckAuthToken())
  1189. {
  1190. RankingModel model = new RankingModel();
  1191. UserInfoRequest user = new UserInfoRequest();
  1192. user.users = Session["msisdn"] as string;
  1193. user.msisdn = Session["msisdn"] as String;
  1194. String rs = UtilsController.SendPost(user, Session.SessionID, UtilsController.WsType.GetRanking);
  1195. System.Diagnostics.Debug.WriteLine("rs: " + rs);
  1196. UserActionResult res = new UserActionResult(rs);
  1197. if (res.status == UtilsController.Constant.SUCCESS)
  1198. {
  1199. Ranking ranking = new Ranking(rs);
  1200. model.ranking = ranking;
  1201. // get current ranking
  1202. for (int i = 0; i < ranking.listRanking.Count; i++)
  1203. {
  1204. if (ranking.listRanking[i].users == Session["msisdn"] as string)
  1205. {
  1206. model.currentRanking = ranking.listRanking[i];
  1207. }
  1208. }
  1209. return PartialView("_ModalRanking", model);
  1210. }
  1211. else
  1212. {
  1213. return Redirect("/Common/Error");
  1214. }
  1215. }
  1216. else
  1217. {
  1218. Session.Clear();
  1219. return Redirect("/Home/Index");
  1220. }
  1221. }
  1222. private void CreateAuthToken()
  1223. {
  1224. // create session authen
  1225. SessionIDManager manager = new SessionIDManager();
  1226. string newSessionId = manager.CreateSessionID(System.Web.HttpContext.Current);
  1227. Response.Cookies["AuthToken"].Value = newSessionId;
  1228. Session["AuthToken"] = newSessionId;
  1229. }
  1230. private bool CheckAuthToken()
  1231. {
  1232. if (Session["AuthToken"] != null && Request.Cookies["AuthToken"] != null)
  1233. {
  1234. if (!Session["AuthToken"].ToString().Equals(Request.Cookies["AuthToken"].Value))
  1235. {
  1236. return false;
  1237. }
  1238. else
  1239. {
  1240. return true;
  1241. }
  1242. }
  1243. else
  1244. {
  1245. return false;
  1246. }
  1247. }
  1248. public RedirectResult Logout()
  1249. {
  1250. Session.Clear();
  1251. return Redirect("/Home/Index");
  1252. }
  1253. }
  1254. }