コード例 #1
0
 public IActionResult GetSchedule(int flightId)
 {
     try
     {
         var scheduleList = _repository.GetSchedulesByFlight(flightId);
         if (scheduleList != null && scheduleList.Count > 0)
         {
             //MakeBooking
             var link = new LinkHelper <List <FlightsSchedule> >(scheduleList);
             for (int iIndex = 0; iIndex < scheduleList.Count || (iIndex < scheduleList.Count && iIndex < 10); iIndex++) // Restrict max 10 links
             {
                 link.Links.Add(new Link
                 {
                     Href   = Url.Link("MakeBooking", new { scheduleList[iIndex].ScheduleId }),
                     Rel    = "post-booking",
                     method = "POST"
                 });
             }
             return(Ok(link));
         }
         else
         {
             return(NotFound("No flight available"));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ExceptionHelper.ProcessError(ex)));
     }
 }