public JsonResult ResendTVEActivationCode(FormCollection fc) { var ReturnCode = new TransactionReturnType() { StatusCode = (int)ErrorCodes.UnknownError, StatusMessage = String.Empty }; string url = Url.Action("Index", "Home").ToString(); try { if (String.IsNullOrEmpty(fc["smartCardNum"]) && String.IsNullOrEmpty(fc["cusAccount"])) { ReturnCode.StatusMessage = "Please fill up the required fields."; } else { if (!User.Identity.IsAuthenticated) { ReturnCode.StatusMessage = "Your session has expired. Please login again."; } else { var context = new IPTV2Entities(); var UserId = new Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == UserId); if (user != null) { var gomsService = new GomsTfcTv(); var response = gomsService.ResendTVEActivationCode(user.EMail, fc["smartCardNum"], fc["cusAccount"], user.LastName); if (response.IsSuccess) { ReturnCode.StatusCode = (int)ErrorCodes.Success; ReturnCode.StatusMessage = response.StatusMessage; } else ReturnCode.StatusMessage = response.StatusMessage; } else ReturnCode.StatusMessage = "User does not exist."; } } } catch (Exception e) { ReturnCode.StatusMessage = e.Message; } return Json(ReturnCode, JsonRequestBehavior.AllowGet); }
public ActionResult _ResendTVEActivationCode(FormCollection fc) { Dictionary<string, object> collection = new Dictionary<string, object>(); ErrorCodes errorCode = ErrorCodes.UnknownError; string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError); collection = MyUtility.setError(errorCode, errorMessage); try { if (String.IsNullOrEmpty(fc["MacAddressOrSmartCard"]) && String.IsNullOrEmpty(fc["AccountNumber"])) { collection = MyUtility.setError(ErrorCodes.IsMissingRequiredFields, "Please fill up the required fields."); return Content(MyUtility.buildJson(collection), "application/json"); } var context = new IPTV2Entities(); User user; if (MyUtility.isUserLoggedIn()) { var userId = new Guid(User.Identity.Name); user = context.Users.FirstOrDefault(u => u.UserId == userId); } else { var userId = (Guid)TempData["tempUid"]; TempData["tempUserId"] = userId; // REASSIGN TempData["tempUid"] = userId; // REASSIGN user = context.Users.FirstOrDefault(u => u.UserId == userId); } if (user != null) { var gomsService = new GomsTfcTv(); var response = gomsService.ResendTVEActivationCode(user.EMail, fc["MacAddressOrSmartCard"], fc["AccountNumber"], user.LastName); if (response.IsSuccess) { collection = MyUtility.setError(ErrorCodes.Success, String.Empty); collection.Add("href", GlobalConfig.RegistrationCompleteTVE); } else collection = MyUtility.setError(ErrorCodes.UnknownError, response.StatusMessage); } else collection = MyUtility.setError(ErrorCodes.UserDoesNotExist, "User does not exist."); } catch (Exception e) { collection = MyUtility.setError(ErrorCodes.UnknownError, e.Message); } return Content(MyUtility.buildJson(collection), "application/json"); }