public virtual ActionResult PurchaseContact(int jigsawId, string contactName, string prevUrl) { JigsawUserPointsViewModel points; try { points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams { RequestingUserId = CurrentUserId }); } catch (JigsawException ex) { if (!(ex is JigsawCredentialsNotFoundException) && !(ex is InvalidJigsawCredentialsException)) { throw; } return(RedirectToAction(MVC.ContactSearch.Jigsaw.Authenticate(Request.RawUrl))); } if (points == null) { throw new JigsawException("User Jigsaw Points structure was null"); } var model = new JigsawContactPurchaseViewModel { Points = points.Points, PurchasePointsUrl = points.PurchasePointsUrl, JigsawContactId = jigsawId, JigsawContactName = contactName, ReturnUrl = prevUrl }; return(View(model)); }
public virtual ActionResult PurchaseContact(JigsawContactPurchaseViewModel model) { if (!model.PurchaseContact) { ModelState.AddModelError("", "You must confirm your purchase request"); } if (!ModelState.IsValid) { // Refresh points information var points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams { RequestingUserId = CurrentUserId }); model.Points = points.Points; model.PurchasePointsUrl = points.PurchasePointsUrl; return(View(model)); } try { _getContactProc.Execute(new GetJigsawContactDetailsParams { RequestingUserId = CurrentUserId, JigsawContactId = model.JigsawContactId, PurchaseContact = true }); } catch (InsufficientJigsawPointsException) { ModelState.AddModelError("", "Your Jigsaw account does not have enough points to make this purchase."); var points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams { RequestingUserId = CurrentUserId }); model.Points = points.Points; model.PurchasePointsUrl = points.PurchasePointsUrl; return(View(model)); } if (!string.IsNullOrWhiteSpace(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } return(RedirectToAction(MVC.ContactSearch.Jigsaw.Index())); }
public virtual ActionResult PurchaseContact(JigsawContactPurchaseViewModel model) { if (!model.PurchaseContact) ModelState.AddModelError("", "You must confirm your purchase request"); if (!ModelState.IsValid) { // Refresh points information var points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams { RequestingUserId = CurrentUserId }); model.Points = points.Points; model.PurchasePointsUrl = points.PurchasePointsUrl; return View(model); } try { _getContactProc.Execute(new GetJigsawContactDetailsParams { RequestingUserId = CurrentUserId, JigsawContactId = model.JigsawContactId, PurchaseContact = true }); } catch (InsufficientJigsawPointsException) { ModelState.AddModelError("", "Your Jigsaw account does not have enough points to make this purchase."); var points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams { RequestingUserId = CurrentUserId }); model.Points = points.Points; model.PurchasePointsUrl = points.PurchasePointsUrl; return View(model); } if (!string.IsNullOrWhiteSpace(model.ReturnUrl)) return Redirect(model.ReturnUrl); return RedirectToAction(MVC.ContactSearch.Jigsaw.Index()); }
public virtual ActionResult PurchaseContact(int jigsawId, string contactName, string prevUrl) { JigsawUserPointsViewModel points; try { points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams { RequestingUserId = CurrentUserId }); } catch (JigsawException ex) { if (!(ex is JigsawCredentialsNotFoundException) && !(ex is InvalidJigsawCredentialsException)) throw; return RedirectToAction(MVC.ContactSearch.Jigsaw.Authenticate(Request.RawUrl)); } if (points == null) throw new JigsawException("User Jigsaw Points structure was null"); var model = new JigsawContactPurchaseViewModel { Points = points.Points, PurchasePointsUrl = points.PurchasePointsUrl, JigsawContactId = jigsawId, JigsawContactName = contactName, ReturnUrl = prevUrl }; return View(model); }