protected void gvEdit_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } string szCode = (string)e.Keys["Code"]; string szType = (string)e.Keys["FacilityTypeCode"]; string szCountry = (string)e.NewValues["Country"]; string szAdmin = (string)e.NewValues["Admin1"]; if (String.IsNullOrWhiteSpace(szCountry) && !String.IsNullOrWhiteSpace(szAdmin)) { lerr.Text = "Can't specify admin without country."; return; } AdminAirport ap = UnReferencedAirports.FirstOrDefault((ap2) => ap2.Code.CompareOrdinal(szCode) == 0 && ap2.FacilityTypeCode.CompareOrdinal(szType) == 0); ap.SetLocale(szCountry, szAdmin); gvEdit.EditIndex = -1; RefreshPending(); }
public override bool Equals(object o) { AdminAirport other = o as AdminAirport; if (other == null) { return(false); } return(ApIatacode.Equals(other.ApIatacode)); }
public ActionResult EditAirport(int id, AdminAirport inAir) { if (ModelState.IsValid) { if (_AdminBll.editAirport(id, inAir)) { return(RedirectToAction("ListAirport")); } } return(RedirectToAction("Error")); }
public bool editAirport(int id, AdminAirport inAir) { if (id == 0) { return(false); } else { return(true); } }
public bool insertAirport(AdminAirport inAir) { if (inAir.Name == "") { return(false); } else { return(true); } }
public ActionResult NewAirport(AdminAirport inAir) { if (ModelState.IsValid) { if (_AdminBll.insertAirport(inAir)) { return(RedirectToAction("ListAirport")); } } return(RedirectToAction("Error")); }
public static void MakeNative(string szCode, string szType) { CheckAdmin(); AdminAirport ap = AdminAirport.AirportWithCodeAndType(szCode, szType); if (ap == null) { throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Airport {0} (type {1}) not found", szCode, szType)); } ap.MakeNative(); }
protected void btnBulkImport_Click(object sender, EventArgs e) { if (!fileUploadAirportList.HasFile) { return; } try { int cAirportsAdded = AdminAirport.BulkImportAirports(fileUploadAirportList.FileContent); lblBulkImportResults.Text = String.Format(CultureInfo.CurrentCulture, "{0} airports added", cAirportsAdded); } catch (MyFlightbookException ex) { lblUploadErr.Text = HttpUtility.HtmlEncode(ex.Message); } }
protected void GeoReferenceForPoly(List <LatLong> rgll, string szCountry, string szAdmin) { if (rgll == null) { throw new ArgumentNullException(nameof(rgll)); } if (szCountry == null) { throw new ArgumentNullException(nameof(szCountry)); } if (!rgll.Any()) { throw new InvalidOperationException("No latitude/longitudes in rgll!"); } // Get the bounding box. LatLongBox llb = new LatLongBox(rgll.First()); foreach (LatLong ll in rgll) { llb.ExpandToInclude(ll); } IEnumerable <airport> rgap = AdminAirport.UntaggedAirportsInBox(llb); GeoRegion geo = new GeoRegion(string.Empty, rgll); int cAirports = 0; foreach (AdminAirport ap in rgap) { if (geo.ContainsLocation(ap.LatLong)) { UpdateString.AppendLine(String.Format(CultureInfo.InvariantCulture, "UPDATE airports SET Country='{0}' {1} WHERE type='{2}' AND airportID='{3}';", szCountry, String.IsNullOrWhiteSpace(szAdmin) ? string.Empty : String.Format(CultureInfo.InvariantCulture, ", admin1 = '{0}' ", szAdmin), ap.FacilityTypeCode, ap.Code)); ap.SetLocale(szCountry, szAdmin); cAirports++; } } if (cAirports > 0) { AuditString.AppendLine(String.Format(CultureInfo.CurrentCulture, "Updated {0} airports for country {1}, region {2}", cAirports, szCountry, szAdmin)); } }
public bool editAirport(int id, AdminAirport inAir) { var db = new WAPPContext(); try { var editAir = db.Airport.Find(id); editAir.Name = inAir.Name; editAir.Country = inAir.Country; db.SaveChanges(); return(true); } catch (Exception exception) { LogException(exception); return(false); } }
public AdminAirport oneAirport(int id) { if (id == 0) { var airport = new AdminAirport(); airport.ID = 0; return(airport); } else { var airport = new AdminAirport() { ID = 1, Name = "Oslo", Country = "Norge" }; return(airport); } }
public static void MergeWith(string szCodeTarget, string szTypeTarget, string szCodeSource) { CheckAdmin(); AdminAirport apTarget = AdminAirport.AirportWithCodeAndType(szCodeTarget, szTypeTarget); if (apTarget == null) { throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Target Airport {0} (type {1}) not found", szCodeTarget, szTypeTarget)); } AdminAirport apSource = AdminAirport.AirportWithCodeAndType(szCodeSource, szTypeTarget); if (apSource == null) { throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Source Airport {0} (type {1}) not found", szCodeSource, szTypeTarget)); } apTarget.MergeFrom(apSource); }
public List <AdminAirport> listAirports() { var port = new AdminAirport() { ID = 1, Name = "Oslo", Country = "Norge" }; var port2 = new AdminAirport() { ID = 2, Name = "Bardufoss", Country = "Norge" }; var list = new List <AdminAirport>(); list.Add(port); list.Add(port2); return(list); }
public bool insertAirport(AdminAirport inAir) { using (var db = new WAPPContext()) { try { var newAir = new Airport(); newAir.Name = inAir.Name; newAir.Country = inAir.Country; db.Airport.Add(newAir); db.SaveChanges(); return(true); } catch (Exception exception) { LogException(exception); return(false); } } }
protected void btnViewMore_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txtCountry.Text) && String.IsNullOrWhiteSpace(txtAdmin.Text)) { ckNoCountry.Checked = ckNoAdmin1.Checked = true; } int start = decStart.IntValue; IEnumerable <AdminAirport> lst = AdminAirport.AirportsMatchingGeoReference(ckNoCountry.Checked ? null : txtCountry.Text, ckNoAdmin1.Checked ? null : txtAdmin.Text, start, decMaxAirports.IntValue); int results = lst.Count(); int last = start + results; lblCurrentRange.Text = String.Format(CultureInfo.CurrentCulture, "Showing results {0} through {1}", start, last); decStart.IntValue = (results < decMaxAirports.IntValue) ? 0 : last; mfbGoogleMapManager.Map.SetAirportList(new AirportList(lst)); UnReferencedAirports = lst; RefreshPending(); }
public AdminAirport oneAirport(int id) { var db = new WAPPContext(); var e = db.Airport.Find(id); if (e == null) { return(null); } else { var one = new AdminAirport() { ID = e.ID, Name = e.Name, Country = e.Country }; return(one); } }
public static void DeleteDupeUserAirport(string idDelete, string idMap, string szUser, string szType) { CheckAdmin(); AdminAirport.DeleteUserAirport(idDelete, idMap, szUser, szType); }
public bool insertAirport(AdminAirport inAir) { return(_repository.insertAirport(inAir)); }
public bool editAirport(int id, AdminAirport inAir) { return(_repository.editAirport(id, inAir)); }