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();
        }
Ejemplo n.º 2
0
    public override bool Equals(object o)
    {
        AdminAirport other = o as AdminAirport;

        if (other == null)
        {
            return(false);
        }
        return(ApIatacode.Equals(other.ApIatacode));
    }
Ejemplo n.º 3
0
 public ActionResult EditAirport(int id, AdminAirport inAir)
 {
     if (ModelState.IsValid)
     {
         if (_AdminBll.editAirport(id, inAir))
         {
             return(RedirectToAction("ListAirport"));
         }
     }
     return(RedirectToAction("Error"));
 }
Ejemplo n.º 4
0
 public bool editAirport(int id, AdminAirport inAir)
 {
     if (id == 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 5
0
 public bool insertAirport(AdminAirport inAir)
 {
     if (inAir.Name == "")
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 6
0
 public ActionResult NewAirport(AdminAirport inAir)
 {
     if (ModelState.IsValid)
     {
         if (_AdminBll.insertAirport(inAir))
         {
             return(RedirectToAction("ListAirport"));
         }
     }
     return(RedirectToAction("Error"));
 }
Ejemplo n.º 7
0
    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();
    }
Ejemplo n.º 8
0
    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));
            }
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
    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);
    }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 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();
        }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
 public static void DeleteDupeUserAirport(string idDelete, string idMap, string szUser, string szType)
 {
     CheckAdmin();
     AdminAirport.DeleteUserAirport(idDelete, idMap, szUser, szType);
 }
Ejemplo n.º 18
0
 public bool insertAirport(AdminAirport inAir)
 {
     return(_repository.insertAirport(inAir));
 }
Ejemplo n.º 19
0
 public bool editAirport(int id, AdminAirport inAir)
 {
     return(_repository.editAirport(id, inAir));
 }