public async Task <ActionResult> ClaimPrizeModal(ClaimPrizeModel model) { if (!ModelState.IsValid) { return(View(model)); } var userId = User.Identity.GetUserId <int>(); var prize = await PrizeReader.GetUserPrize(userId, model.Id); if (prize.Status != PrizeStatus.Unclaimed) { return(CloseModalSuccess()); } if (model.IsPointsClaim) { var paymentMethod = await PaymentReader.GetMethod(prize.Data); if (paymentMethod == null) { return(CloseModalError("Unknown Error")); } var paymentUserMethod = await PaymentReader.GetUserMethod(userId, paymentMethod.Id); if (paymentUserMethod == null) { await PaymentWriter.CreateMethod(userId, paymentMethod.Id); } paymentUserMethod = await PaymentReader.GetUserMethod(userId, paymentMethod.Id); if (paymentUserMethod == null) { return(CloseModalError("Unknown Error")); } model.Data3 = paymentUserMethod.Data; } if (string.IsNullOrEmpty(model.Data3)) { ModelState.AddModelError("", "Invalid Crypto Address"); return(View(model)); } var result = await PrizeWriter.ClaimPrize(userId, model); if (!ModelState.IsWriterResultValid(result)) { return(View(model)); } return(CloseModalSuccess()); }
public async Task <ActionResult> MethodModal(int id) { var userId = User.Identity.GetUserId <int>(); var paymentMethod = await PaymentReader.GetUserMethod(userId, id); if (paymentMethod != null) { return(View(paymentMethod)); } var result = await PaymentWriter.CreateMethod(userId, id); if (result.Success) { paymentMethod = await PaymentReader.GetUserMethod(userId, id); if (paymentMethod != null) { return(View(paymentMethod)); } } return(View("ErrorModal")); }