示例#1
0
        public async Task <ActionResult> List(string originalLocationCode, string originalLocation, string destinationLocationCode, string destinationLocation, string departureDate, string returnDate, short?adults, short?children, short?infants, string travelClass, string currencyCode, bool?nonStop, int?page)
        {
            try
            {
                if (String.IsNullOrEmpty(originalLocationCode) || String.IsNullOrEmpty(destinationLocationCode) || String.IsNullOrEmpty(departureDate))
                {
                    return(null);
                }

                int pageSize   = 10;
                int pageNumber = (page ?? 1);

                FlightOfferSearch flightOfferSearch = new FlightOfferSearch();
                flightOfferSearch.CreateOffer(originalLocationCode, destinationLocationCode, departureDate, returnDate, adults, children, infants, travelClass, currencyCode, nonStop);
                FlightOfferSearch search = await FlightOfferSearchesRepo.ReadByUrl(flightOfferSearch.URLQuery);

                if (search == null)
                {
                    int searchId = await AmadeusRepo.PassToDatabase(flightOfferSearch);

                    search = await FlightOfferSearchesRepo.ReadById(searchId);

                    return(PartialView(search.FlightOfferResults.ToPagedList(pageNumber, pageSize)));
                }
                else
                {
                    return(PartialView(search.FlightOfferResults.ToList().ToPagedList(pageNumber, pageSize)));
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public async Task <JsonResult> DeleteSearches()
        {
            try
            {
                await FlightOfferSearchesRepo.DeleteAllSearches();

                return(Json(new { Message = "Uspješno obrisano!" }));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = ex.Message }));
            }
        }