Ejemplo n.º 1
0
 public ActionResult Post([FromBody] FlightPlan fpDetails)
 {
     if (ModelState.IsValid)
     {
         string key = fpDetails.GenerateId();
         cache.Set(key, fpDetails);
         // Updating the keys list with a new key.
         var keysList = (List <string>)cache.Get("keys");
         keysList.Add(key);
         cache.Set("keys", keysList);
         // Save the flight id in the response headers (for testing it).
         HttpContext.Response.Headers["Location"] = key;
         var resp = CreatedAtAction(actionName: "Get", new { id = key }, fpDetails);
         return(resp);
     }
     return(BadRequest("Not a valid flight plan"));
 }