public async Task<IHttpActionResult> Save(Query model)
 {
     if (!ModelState.IsValid)
         return BadRequest(ModelState);
     await Task.Delay(1);
     return Ok();
 }
 private async Task<HttpResponseMessage> Save(Query model) // simulate saving through WebAPI call
 {
     using (var client = new HttpClient())
     {
         Debug.Assert(Request.Url != null);
         client.BaseAddress = new Uri($"{Request.Url.Scheme}://{Request.Url.Authority}/");
         return await client.PostAsync("api/Default/Save", model, new JsonMediaTypeFormatter());
     }
 }
        public ActionResult Index(Query model)
        {
            if (ModelState.IsValid)
            {
                TempData["Success"] = "Query successfully submitted";
                return RedirectToAction("Index"); // PRG to avoid subsequent form submission attempts on page refresh (http://en.wikipedia.org/wiki/Post/Redirect/Get)
            }

            return View("Home", model);
        }
 public ActionResult Index()
 {
     var model = new Query
     {
         GoAbroad = true,
         Country = "Poland",
         NextCountry = "Other",
         SportType = "Extreme",
         AgreeForContact = false,
         LatestSuggestedReturnDate = DateTime.Today.AddMonths(1),
         ContactDetails = new Contact()
     };
     return View("Home", model);
 }
        public ActionResult Index()
        {
            var model = new Query
            {
                GoAbroad = true,
                Country = "Poland",
                NextCountry = "Other",
                SportType = "Extreme",
                AgreeForContact = false,
                LatestSuggestedReturnDate = DateTime.Today.AddMonths(1)
            };

            ViewBag.Success = TempData["Success"];
            return View("Home", TempData["Query"] as Query ?? model);
        }
        public async Task<ActionResult> Index(Query model)
        {
            Session["Postbacks"] = (int) Session["Postbacks"] + 1;
            if (ModelState.IsValid)
            {
                var result = await Save(model);
                if (!result.IsSuccessStatusCode)
                    throw new ApplicationException("Unexpected failure in WebAPI pipeline.");

                TempData["Postbacks"] = Session["Postbacks"];
                TempData["Success"] = "[query successfully submitted]";
                TempData["Query"] = model;
                return RedirectToAction("Index"); // PRG to avoid subsequent form submission attempts on page refresh (http://en.wikipedia.org/wiki/Post/Redirect/Get)
            }

            return View("Home", model);
        }
 public ActionResult Index(Query model)
 {
     if (ModelState.IsValid)
         ViewBag.Success = "Success";
     return View("Home", model);
 }
 public ActionResult Index()
 {
     var model = new Query {SportType = "Extreme", GoAbroad = true};
     return View("Home", model);
 }