public ActionResult SubscribeBenchH2HFUT(SubscribeBench model) { if (!ModelState.IsValid) { ViewBag.Message = "ModeState is invalid"; return(View(model)); } if (model.checkH2H == false && model.checkFUT == false) { ModelState.AddModelError("checkH2H", "Nenhuma modalidade selecionada. Você de ve selecionar a Modalidade H2H e/ou FUT."); ModelState.AddModelError("checkFUT", "Nenhuma modalidade selecionada. Você de ve selecionar a Modalidade H2H e/ou FUT."); return(View(model)); } else { HttpResponseMessage response = null; SubscribeBench modelReturnJSON = null; try { model.id = Convert.ToInt16(Session["user.id"]); response = GlobalVariables.WebApiClient.PostAsJsonAsync("SubscribeBench", model).Result; modelReturnJSON = response.Content.ReadAsAsync <SubscribeBench>().Result; switch (response.StatusCode) { case HttpStatusCode.Created: if (modelReturnJSON.returnMessage == "subscribeBenchSuccessfully") { return(RedirectToAction("SubscribeBenchConfirmation", "Home", model)); } else { //ModelState.AddModelError("", "Senha Atual inválida! Favor tentar novamente."); TempData["returnMessage"] = "Ocorreu algum erro na inscrição do banco de Reservas H2H e/ou FUT. (" + modelReturnJSON.returnMessage + ")"; return(View(model)); } default: TempData["returnMessage"] = "Ocorreu algum erro na inscrição do banco de Reservas H2H e/ou FUT. (" + response.StatusCode + ")"; ModelState.AddModelError("", "application error."); return(View(model)); } } catch (Exception ex) { TempData["returnMessage"] = "Erro interno - inscrevendo-se no banco - H2H e/ou FUT: (" + ex.InnerException.Message + ")"; ModelState.AddModelError("", "application error."); return(View(model)); } finally { response = null; modelReturnJSON = null; } } }
public IHttpActionResult subscribe(SubscribeBench model) { db.openConnection(); try { if (model.checkH2H) { paramName = new string[] { "pIdUsu", "pNmTime", "pTpBanco" }; paramValue = new string[] { Convert.ToString(model.id), "", "H2H" }; db.executePROCNonResult("spAddBancoReserva", paramName, paramValue); } if (model.checkFUT) { paramName = new string[] { "pIdUsu", "pNmTime", "pTpBanco" }; paramValue = new string[] { Convert.ToString(model.id), model.teamNameFUT, "FUT" }; db.executePROCNonResult("spAddBancoReserva", paramName, paramValue); } if (model.checkPRO) { paramName = new string[] { "pIdUsu", "pNmTime", "pTpBanco" }; paramValue = new string[] { Convert.ToString(model.id), model.teamNamePRO, "PRO" }; db.executePROCNonResult("spAddBancoReserva", paramName, paramValue); if (!String.IsNullOrWhiteSpace(model.mobile)) { paramName = new string[] { "pIdUsuario", "pDDD", "pMobile" }; paramValue = new string[] { Convert.ToString(model.id), model.ddd, model.mobile }; db.executePROCNonResult("spUpdateMobile", paramName, paramValue); } } model.returnMessage = "subscribeBenchSuccessfully"; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } catch (Exception ex) { model = new SubscribeBench(); model.returnMessage = "error_" + ex.Message; return(CreatedAtRoute("DefaultApi", new { id = 0 }, model)); } finally { db.closeConnection(); } }
public ActionResult SubscribeBenchConfirmation(SubscribeBench model) { return(View(model)); }