public async Task <JsonResult> SearchAirports(string search, string otherSearch) { List <Airport> airports = await AirportsRepo.Search(search, otherSearch); var airportList = airports.Select(a => new { a.IATA, a.Name, a.Location }); return(Json(airportList, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> DeleteAirports() { try { await AirportsRepo.DeleteAll(); return(Json(new { Message = "Uspješno obrisano!" })); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = ex.Message })); } }
public async Task <JsonResult> ScapreAirports() { try { int count = await AirportsRepo.Count(); if (count == 0) { List <Airport> airports = AirportsRepo.ScrapeAllAirports(); foreach (Airport airport in airports) { await AirportsRepo.Create(airport); } return(Json(new { Message = "Uspješno spremljeni aerodromi!" })); } return(Json(new { Message = "" })); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = ex.Message + " Molim ponovno učitajte stranicu." })); } }