// GET: GreenCardRequests/Edit/5 public async Task <ActionResult> Edit(Guid id) { if (string.IsNullOrWhiteSpace(SessionManager.BearerToken)) { return(RedirectToAction("Index", "Home")); } GreenCardRequestModification model = new GreenCardRequestModification { CorrelationId = id }; return(View(model)); }
public async Task <ActionResult> Edit(GreenCardRequestModification model) { if (string.IsNullOrWhiteSpace(SessionManager.BearerToken)) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { using (SDK.Clients.CarGreenCardClient client = new SDK.Clients.CarGreenCardClient(new AssurBoxClientOptions { Environment = AssurBoxEnvironments.Test, ApiKey = SessionManager.BearerToken })) { try { var creationResult = await client.ChangeRequest(model); return(RedirectToAction("Details", new { id = creationResult.ResponseContent })); } catch (AssurBoxException ex) { ModelState.AddModelError("", "An error occured " + ex.Message); try { ModelState.AddModelError("", ex.ErrorDetail.Error.Message); foreach (var err in ex.ErrorDetail.Error.Details) { ModelState.AddModelError("", err.Message); } } catch { } } } } return(View(model)); }