protected void btnMigrateSim_Click(object sender, EventArgs e)
        {
            Aircraft acOriginal = new Aircraft(MfbEditAircraft1.AircraftID);
            int      idNew      = AircraftUtility.MapToSim(acOriginal);

            if (idNew == Aircraft.idAircraftUnknown)
            {
                lblErr.Text = Resources.Aircraft.AdminNotASim;
            }
            else
            {
                Response.Redirect(Request.Url.PathAndQuery.Replace(String.Format(CultureInfo.InvariantCulture, "id={0}", acOriginal.AircraftID), String.Format(CultureInfo.InvariantCulture, "id={0}", idNew)));
            }
        }
Esempio n. 2
0
        public static void MigrateSim(int idAircraft)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated || String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
            {
                throw new MyFlightbookException("Unauthenticated call to MigrateSim");
            }

            Aircraft ac = new Aircraft(idAircraft);

            if (String.IsNullOrWhiteSpace(ac.TailNumber) || ac.AircraftID <= 0)
            {
                throw new MyFlightbookValidationException(String.Format(CultureInfo.CurrentCulture, "No aircraft with ID {0}", idAircraft));
            }

            if (AircraftUtility.MapToSim(ac) < 0)
            {
                throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Unable to map aircraft {0}", ac.TailNumber));
            }
        }