public FlightSchedule Load()
        {
            var Montreal  = new IATA("YUL");
            var Toronto   = new IATA("YYZ");
            var Calgary   = new IATA("YYC");
            var Vancouver = new IATA("YVR");
            var data      = new Dictionary <int, IReadOnlyList <Flight> >
            {
                {
                    1, new List <Flight>(3)
                    {
                        new Flight(1, Montreal, Toronto),
                        new Flight(2, Montreal, Calgary),
                        new Flight(3, Montreal, Vancouver),
                    }
                },
                {
                    2, new List <Flight>(3)
                    {
                        new Flight(4, Montreal, Toronto),
                        new Flight(5, Montreal, Calgary),
                        new Flight(6, Montreal, Vancouver),
                    }
                }
            };
            var schedule = new FlightSchedule(data);

            return(schedule);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            var station = obj as Station;

            if (obj == null)
            {
                return(false);
            }

            return((StationName == null && station.StationName == null ||
                    StationName != null && StationName.Equals(station.StationName)) &&
                   (StateCountryName == null && station.StateCountryName == null ||
                    StateCountryName != null && StateCountryName.Equals(station.StateCountryName)) &&
                   (StateProvinceAbbrev == null && station.StateProvinceAbbrev == null ||
                    StateProvinceAbbrev != null && StateProvinceAbbrev.Equals(station.StateProvinceAbbrev)) &&
                   (ICAO == null && station.ICAO == null ||
                    ICAO != null && ICAO.Equals(station.ICAO)) &&
                   (IATA == null && station.IATA == null ||
                    IATA != null && IATA.Equals(station.IATA)) &&
                   SYNOP == station.SYNOP &&
                   (Latitude == null && station.Latitude == null ||
                    Latitude != null && Latitude.Equals(station.Latitude)) &&
                   (Longitude == null && station.Longitude == null ||
                    Longitude != null && Longitude.Equals(station.Longitude)) &&
                   Elevation == station.Elevation &&
                   METAR == station.METAR &&
                   RADAR == station.RADAR &&
                   AviationFlag == station.AviationFlag &&
                   UpperAir == station.UpperAir &&
                   ObservationSystem == station.ObservationSystem &&
                   OfficeType == station.OfficeType &&
                   (Country == null && station.Country == null ||
                    Country != null && Country.Equals(station.Country)) &&
                   Priority == Priority);
        }
        private void txtIATA_TextChanged(object sender, EventArgs e)
        {
            if (txtIATA.Text.Length == 9)
            {
                IATA iata = GetAllFirmModulesBL.GetIATA(txtIATA.Text);

                if (!string.IsNullOrEmpty(iata.Code))
                {
                    txtIATA.Text    = iata.Code;
                    txtIATA.Enabled = true;
                    txtOffice.Text  = iata.Office;
                    txtPCC.Text     = iata.Pcc;
                    txtOffice.Focus();
                }
                else
                {
                    MessageBox.Show("El número de IATA no existe, debe ser dado de alta", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtIATA.Text    = string.Empty;
                    txtOffice.Text  = string.Empty;
                    txtPCC.Text     = string.Empty;
                    txtIATA.Enabled = true;
                    txtIATA.Focus();
                }
            }
        }
示例#4
0
        public ActionResult UnDelete(int id)
        {
            IATA iata = new IATA();

            iata = iataRepository.GetIATA(id);

            //Check Exists
            if (iata == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            IATAVM iataVM = new IATAVM();

            //Attached Items - To show and not to prevent Delete
            List <IATAReference> iataReferences = iataRepository.GetIATAReferences(iata.IATAId);

            iataVM.IATAReferences = iataReferences;

            iataVM.IATA = iata;

            return(View(iataVM));
        }
示例#5
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            IATA iata = iataRepository.GetIATA(id);

            //Check Exists
            if (iata == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            IATAVM iataVM = new IATAVM();

            iataVM.IATA = iata;

            return(View(iataVM));
        }
示例#6
0
        // override object.Equals
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            return(IATA.ToLower().Trim().Equals(((Airport)obj).IATA.Trim().ToLower()));
        }
        public ScheduledFlight ScheduleFlightAndBookItem(IATA destination)
        {
            var flight = _flights.FirstOrDefault(x => x.To == destination && x.CurrectCapacity < PlainCapacity);

            if (flight != null)
            {
                flight.CurrectCapacity++;
            }
            return(flight);
        }
示例#8
0
        public ActionResult Create()
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            IATAVM iataVM = new IATAVM();
            IATA   iata   = new IATA();

            iataVM.IATA = iata;

            return(View(iataVM));
        }
示例#9
0
        public ActionResult UnDelete(IATAVM iataVM, FormCollection collection)
        {
            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Get Item From Database
            IATA iata = new IATA();

            iata = iataRepository.GetIATA(iataVM.IATA.IATAId);

            //Check Exists
            if (iata == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Delete Item
            try
            {
                iataVM.IATA.DeletedFlag = false;
                iataRepository.UpdateDeletedStatus(iataVM);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/IATA.mvc/Delete/" + iata.IATAId;
                    return(View("VersionError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }
            return(RedirectToAction("ListDeleted"));
        }
        public IATA GetIATA(string connectionName)
        {
            Database  db        = DatabaseFactory.CreateDatabase(connectionName);
            DbCommand dbCommand = db.GetStoredProcCommand(Resources.GetAllFirmMOdulesForNewUserResources.SP_GetIATAForNewUser);
            IATA      iata      = new IATA();

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                int _iata = dr.GetOrdinal(Resources.GetAllFirmMOdulesForNewUserResources.PARAM_IATA);

                if (dr.Read())
                {
                    iata.Code = (dr[_iata] == DBNull.Value) ? Types.StringNullValue : dr.GetString(_iata);
                }
            }

            return(iata);
        }
示例#11
0
        public static IATA GetIATA(string ta)
        {
            IATA objIATA = new IATA();
            GetAllFirmModulesDAL objGet = new GetAllFirmModulesDAL();

            try
            {
                try
                {
                    objIATA = objGet.GetIATA(ta, CommonENT.MYCTSDBSECURITY_CONNECTION);
                }
                catch
                {
                    objIATA = objGet.GetIATA(ta, CommonENT.MYCTSDBSECURITYBACKUP_CONNECTION);
                }
            }
            catch { }

            return(objIATA);
        }
        public IATA GetIATA()
        {
            IATA iata = new IATA();
            GetAllFirmModulesForNewUserDAL objGetIATA = new GetAllFirmModulesForNewUserDAL();

            try
            {
                try
                {
                    iata = objGetIATA.GetIATA(CommonENT.MYCTSDBSECURITY_CONNECTION);
                }
                catch
                {
                    iata = objGetIATA.GetIATA(CommonENT.MYCTSDBSECURITYBACKUP_CONNECTION);
                }
            }
            catch
            {
            }

            return(iata);
        }
        public IATA GetIATA(string iata, string connectionName)
        {
            Database  db        = DatabaseFactory.CreateDatabase(connectionName);
            DbCommand dbCommand = db.GetStoredProcCommand(Resources.GetAllFirmModulesResources.SP_GetIATA);

            db.AddInParameter(dbCommand, Resources.GetAllFirmModulesResources.PARAM_IATA, DbType.String, iata);
            IATA objIATA = new IATA();

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                int _iata   = dr.GetOrdinal(Resources.GetAllFirmModulesResources.PARAM_IATA);
                int _office = dr.GetOrdinal(Resources.GetAllFirmModulesResources.PARAM_OFFICE);
                int _pcc    = dr.GetOrdinal(Resources.GetAllFirmModulesResources.PARAM_PCC);


                if (dr.Read())
                {
                    objIATA.Code   = (dr[_iata] == DBNull.Value) ? Types.StringNullValue : dr.GetString(_iata);
                    objIATA.Office = (dr[_office] == DBNull.Value) ? Types.StringNullValue : dr.GetString(_office);
                    objIATA.Pcc    = (dr[_pcc] == DBNull.Value) ? Types.StringNullValue : dr.GetString(_pcc);
                }
            }
            return(objIATA);
        }
示例#14
0
 public Flight(int id, IATA from, IATA to)
 {
     Id   = id;
     From = from;
     To   = to;
 }
 public IATAVM(IATA iata, List <IATAReference> iataReferences)
 {
     IATA           = iata;
     IATAReferences = iataReferences;
 }
示例#16
0
 public Order(string id, IATA destination)
 {
     Id          = id;
     Destination = destination;
 }