public ActionResult RevivalRequest(PlanReivalRequestViewModel ReviveRequest, string UId, string CoId, string StId, string Plan, PlanType planType) { var uid = EncryptionHelper.Unprotect(UId); var ruid = EncryptionHelper.Unprotect(ReviveRequest.userId); var coid = EncryptionHelper.Unprotect(CoId); var rcoid = EncryptionHelper.Unprotect(ReviveRequest.coId); var stid = EncryptionHelper.Unprotect(StId); var rstid = EncryptionHelper.Unprotect(ReviveRequest.storeId); if (ModelState.IsValid) { RevivalRequest revivalToInsert = new RevivalRequest(); if (rcoid == coid && coid != null && rstid == null && ruid == null && planType == PlanType.Company && PlansPrices.CompanyPlans.ContainsKey(Plan)) { revivalToInsert.coID = EncryptionHelper.Unprotect(ReviveRequest.coId); } else if (rstid == stid && stid != null && rcoid == null && ruid == null && planType == PlanType.Store && PlansPrices.StorePlans.ContainsKey(Plan)) { revivalToInsert.storeID = EncryptionHelper.Unprotect(ReviveRequest.storeId); } else if (ruid == uid && uid != null && rcoid == null && rstid == null && planType == PlanType.User && PlansPrices.UserPlans.ContainsKey(Plan)) { revivalToInsert.userID = EncryptionHelper.Unprotect(ReviveRequest.userId); } else { throw new JsonCustomException(ControllerError.ajaxError); } revivalToInsert.reqDate = DateTime.UtcNow; revivalToInsert.planType = ReviveRequest.planType; revivalToInsert.plan = ReviveRequest.plan; revivalToInsert.requesterUserID = WebSecurity.CurrentUserId; unitOfWork.RevivalPlanRequestRepository.Insert(revivalToInsert); unitOfWork.Save(); return(Json(new { URL = Url.Action("PayForPlan", "Payment", new { reqId = EncryptionHelper.Protect(revivalToInsert.reqID) }) })); //return RedirectToAction("PayForPlan", "Payment", new { reqId = EncryptionHelper.Protect(revivalToInsert.reqID) }); } else { throw new ModelStateException(this.ModelState); } }
public ActionResult RevivalRequest(string UId, string CoId, string StId, string Plan, PlanType planType) { PlanReivalRequestViewModel viewmodel = new PlanReivalRequestViewModel(); var uid = EncryptionHelper.Unprotect(UId); var coid = EncryptionHelper.Unprotect(CoId); var stid = EncryptionHelper.Unprotect(StId); if (coid != null && PlansPrices.CompanyPlans.ContainsKey(Plan)) { var company = unitOfWork.CompanyRepository.GetByID(coid); if (company.Admins.Any(u => u.UserId == WebSecurity.CurrentUserId)) { viewmodel.companyToRevive = company; viewmodel.coId = CoId; } else { return(new RedirectToError()); } } else if (stid != null && PlansPrices.StorePlans.ContainsKey(Plan)) { var store = unitOfWork.StoreRepository.GetByID(stid); if (store.Admins.Any(u => u.UserId == WebSecurity.CurrentUserId)) { viewmodel.storeToRevive = store; viewmodel.storeId = StId; } else { return(new RedirectToError()); } } else if (uid != null && PlansPrices.UserPlans.ContainsKey(Plan)) { var user = unitOfWork.ActiveUserRepository.GetByID(uid); if (user.UserId == WebSecurity.CurrentUserId) { viewmodel.userToRevive = user; viewmodel.userId = UId; } else { return(new RedirectToError()); } } else { return(new RedirectToError()); } viewmodel.plan = Plan; viewmodel.planType = planType; return(View(viewmodel)); }