Ejemplo n.º 1
0
        // update all object members on a row in table based on primary key
        // links:
        //  docLink: http://sql2x.org/documentationLink/ce75e72e-fb16-4f4e-a2e6-dbd079dfa206
        public void Update(CrudeFlightSegmentContract contract)
        {
            var data = new CrudeFlightSegmentData();

            ContractToData(contract, data);
            data.Update();
        }
Ejemplo n.º 2
0
        // update all object members on a row in table based on primary key, on a transaction
        // the transaction and or connection state is not changed in any way other than what SqlClient does to it.
        // it is the callers responsibility to commit or rollback the transaction
        // links:
        //  docLink: http://sql2x.org/documentationLink/b798ad6b-f4b8-466a-9086-6588a814fcf3
        public void Update(CrudeFlightSegmentContract contract, SqlConnection connection, SqlTransaction transaction)
        {
            var data = new CrudeFlightSegmentData();

            ContractToData(contract, data);
            data.Update(connection, transaction);
        }
Ejemplo n.º 3
0
        // fetch all rows from table into new List of Contracts, filtered by any column
        // links:
        //  docLink: http://sql2x.org/documentationLink/ce01ef4a-5cd0-4e51-b211-9c0a15b791a0
        public List <CrudeFlightSegmentContract> FetchWithFilter(System.Guid flightSegmentId, System.Guid flightId, System.Guid departureAirportId, System.Guid arrivalAirportId, int logicalSegmentNumber, int physicalSegmentNumber, System.DateTime fromDateTime, System.DateTime untilDateTime, string departureGate, string arrivalGate, System.Guid userId, System.DateTime dateTime)
        {
            var list = new List <CrudeFlightSegmentContract>();
            List <CrudeFlightSegmentData> dataList = CrudeFlightSegmentData.FetchWithFilter(
                flightSegmentId: flightSegmentId,
                flightId: flightId,
                departureAirportId: departureAirportId,
                arrivalAirportId: arrivalAirportId,
                logicalSegmentNumber: logicalSegmentNumber,
                physicalSegmentNumber: physicalSegmentNumber,
                fromDateTime: fromDateTime,
                untilDateTime: untilDateTime,
                departureGate: departureGate,
                arrivalGate: arrivalGate,
                userId: userId,
                dateTime: dateTime
                );

            foreach (CrudeFlightSegmentData data in dataList)
            {
                var crudeFlightSegmentContract = new CrudeFlightSegmentContract();
                DataToContract(data, crudeFlightSegmentContract);
                list.Add(crudeFlightSegmentContract);
            }

            return(list);
        }
Ejemplo n.º 4
0
        // insert all object members as a new row in table
        // links:
        //  docLink: http://sql2x.org/documentationLink/75aad010-e6aa-4f19-a6e5-597456aa20d8
        public void Insert(CrudeFlightSegmentContract contract)
        {
            var data = new CrudeFlightSegmentData();

            ContractToData(contract, data);
            data.Insert();
        }
Ejemplo n.º 5
0
        // transfer model to data and update, on a transaction
        // links:
        //  docLink: http://sql2x.org/documentationLink/aa07e05b-edc8-4e09-bf93-bf2a40c93c09
        public void Update(CrudeFlightSegmentModel model, SqlConnection connection, SqlTransaction transaction)
        {
            var data = new CrudeFlightSegmentData();

            ModelToData(model, data);
            data.Update(connection, transaction);
        }
Ejemplo n.º 6
0
        // transfer model to data and update
        // links:
        //  docLink: http://sql2x.org/documentationLink/658fda50-2ad3-414e-9299-2b399d17a057
        public void Update(CrudeFlightSegmentModel model)
        {
            var data = new CrudeFlightSegmentData();

            ModelToData(model, data);
            data.Update();
        }
Ejemplo n.º 7
0
        /// <summary>get all segments for flight</summary>
        public static List <CrudeFlightSegmentData> GetFlightSegments(System.Guid flightId)
        {
            var dataList = new List <CrudeFlightSegmentData>();

            string sql = @" 
                select 
	                flight_segment_id, flight_id, departure_airport_id, arrival_airport_id, logical_segment_number, physical_segment_number, from_date_time, until_date_time, departure_gate, arrival_gate, user_id, date_time
                from flight_segment	as fs	
                where fs.flight_id = @flight_id
                order by fs.physical_segment_number
            ";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();

                using (var command = new SqlCommand(sql, conn)) {
                    command.Parameters.Add("@flight_id", SqlDbType.UniqueIdentifier).Value = flightId;

                    Logging     log    = Logging.PerformanceTimeStart("SolutionNorSolutionPort.DataAccessLayer.Flight.GetFlightSegments");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    while (reader.Read())
                    {
                        var data = new CrudeFlightSegmentData();
                        data.Populate(reader);
                        dataList.Add(data);
                    }
                }

                return(dataList);
            }
        }
Ejemplo n.º 8
0
        // transfer model to data and insert
        // links:
        //  docLink: http://sql2x.org/documentationLink/17cd8423-3c78-459f-a45b-773fcfbc3b7d
        public void Insert(CrudeFlightSegmentModel model)
        {
            var data = new CrudeFlightSegmentData();

            ModelToData(model, data);
            data.Insert();
        }
Ejemplo n.º 9
0
 // copy all rows from a List of SOAP Contracts to a List of serialized data objects
 // links:
 //  docLink: http://sql2x.org/documentationLink/1c6c6b9c-e201-4590-8c69-d38a0ad2a9f7
 public static void ContractListToDataList(List <CrudeFlightSegmentContract> contractList, List <CrudeFlightSegmentData> dataList)
 {
     foreach (CrudeFlightSegmentContract contract in contractList)
     {
         var data = new CrudeFlightSegmentData();
         CrudeFlightSegmentService.ContractToData(contract, data);
         dataList.Add(data);
     }
 }
Ejemplo n.º 10
0
 // transfer model list to data list
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/1d6a48d9-fe39-4397-b8fa-a332da164cbf
 // parameters:
 //  CrudeFlightSegmentData: key of table CrudeFlightSegmentData
 public static void ModelListToDataList(List <CrudeFlightSegmentModel> modelList, List <CrudeFlightSegmentData> dataList)
 {
     foreach (CrudeFlightSegmentModel model in modelList)
     {
         var data = new CrudeFlightSegmentData();
         ModelToData(model, data);
         dataList.Add(data);
     }
 }
Ejemplo n.º 11
0
        // fetch by Primary key into current object
        // links:
        //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
        //  docLink: http://sql2x.org/documentationLink/fdcc33b4-08f1-43c3-ae28-95fbf029c3bd
        // parameters:
        //  CrudeFlightSegmentData: primary key of table CrudeFlightSegmentData
        public CrudeFlightSegmentModel FetchByFlightSegmentId(System.Guid flightSegmentId)
        {
            var dataAccessLayer = new CrudeFlightSegmentData();
            var model           = new CrudeFlightSegmentModel();

            dataAccessLayer.FetchByFlightSegmentId(flightSegmentId);
            DataToModel(dataAccessLayer, model);

            return(model);
        }
Ejemplo n.º 12
0
        // fetch by Primary key into current object
        // links:
        //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
        //  docLink: http://sql2x.org/documentationLink/bbab4791-c9e7-49bf-90d5-fca19b1fedaa
        // parameters:
        //  flightSegmentId: primary key of table flight_segment
        public CrudeFlightSegmentContract FetchByFlightSegmentId(System.Guid flightSegmentId)
        {
            var dataAccessLayer = new CrudeFlightSegmentData();
            var contract        = new CrudeFlightSegmentContract();

            dataAccessLayer.FetchByFlightSegmentId(flightSegmentId);
            DataToContract(dataAccessLayer, contract);

            return(contract);
        }
Ejemplo n.º 13
0
        // fetch all rows from table with an offset, and limit of rows
        // links:
        //  docLink: http://sql2x.org/documentationLink/a87e5c54-b47e-4031-bc3b-837b4cf9f692
        public List <CrudeFlightSegmentModel> FetchAllWithLimitAndOffset(string limit, string offset)
        {
            var list = new List <CrudeFlightSegmentModel>();
            List <CrudeFlightSegmentData> dataList = CrudeFlightSegmentData.FetchAllWithLimitAndOffset(int.Parse(limit), int.Parse(offset));

            foreach (CrudeFlightSegmentData crudeFlightSegmentBusiness in dataList)
            {
                var model = new CrudeFlightSegmentModel();
                DataToModel(crudeFlightSegmentBusiness, model);
                list.Add(model);
            }

            return(list);
        }
Ejemplo n.º 14
0
        // copy all rows from a List of serialized data objects in CrudeFlightSegmentData to a List of SOAP Contracts
        // links:
        //  docLink: http://sql2x.org/documentationLink/3d3e60c3-69e4-43d6-8bd5-14a67a6ecf58
        public List <CrudeFlightSegmentModel> FetchAll()
        {
            var list = new List <CrudeFlightSegmentModel>();
            List <CrudeFlightSegmentData> dataList = CrudeFlightSegmentData.FetchAll();

            foreach (CrudeFlightSegmentData crudeFlightSegmentBusiness in dataList)
            {
                var model = new CrudeFlightSegmentModel();
                DataToModel(crudeFlightSegmentBusiness, model);
                list.Add(model);
            }

            return(list);
        }
Ejemplo n.º 15
0
        // copy all rows from a List of serialized data objects in CrudeFlightSegmentData to a List of SOAP Contracts
        // links:
        //  docLink: http://sql2x.org/documentationLink/9204c68e-93b8-4c77-af3c-3181985ff75f
        public List <CrudeFlightSegmentContract> FetchAll()
        {
            var list = new List <CrudeFlightSegmentContract>();
            List <CrudeFlightSegmentData> dataList = CrudeFlightSegmentData.FetchAll();

            foreach (CrudeFlightSegmentData crudeFlightSegment in dataList)
            {
                var contract = new CrudeFlightSegmentContract();
                DataToContract(crudeFlightSegment, contract);
                list.Add(contract);
            }

            return(list);
        }
Ejemplo n.º 16
0
        // copy all rows from a List of serialized data objects to a List of SOAP Contracts,
        //  with a limit on number of returned rows and order by columns, starting at a specific row
        // links:
        //  docLink: http://sql2x.org/documentationLink/3fe9f1b3-97b6-4f58-a0f2-adfcbd973bfc
        public List <CrudeFlightSegmentContract> FetchAllWithLimitAndOffset(int limit, int offset)
        {
            var list = new List <CrudeFlightSegmentContract>();
            List <CrudeFlightSegmentData> dataList = CrudeFlightSegmentData.FetchAllWithLimitAndOffset(limit, offset);

            foreach (CrudeFlightSegmentData crudeFlightSegment in dataList)
            {
                var contract = new CrudeFlightSegmentContract();
                DataToContract(crudeFlightSegment, contract);
                list.Add(contract);
            }

            return(list);
        }
Ejemplo n.º 17
0
        // fetch all from table into new List of class instances, filtered by any column
        // links:
        //  docLink: http://sql2x.org/documentationLink/db27658d-4d23-46d7-9970-7bbaef8634b0
        public List <CrudeFlightSegmentModel> FetchWithFilter(System.Guid flightSegmentId, System.Guid flightId, System.Guid departureAirportId, System.Guid arrivalAirportId, int logicalSegmentNumber, int physicalSegmentNumber, System.DateTime fromDateTime, System.DateTime untilDateTime, string departureGate, string arrivalGate, System.Guid userId, System.DateTime dateTime)
        {
            var list = new List <CrudeFlightSegmentModel>();
            List <CrudeFlightSegmentData> dataList = CrudeFlightSegmentData.FetchWithFilter(flightSegmentId, flightId, departureAirportId, arrivalAirportId, logicalSegmentNumber, physicalSegmentNumber, fromDateTime, untilDateTime, departureGate, arrivalGate, userId, dateTime);

            foreach (CrudeFlightSegmentData data in dataList)
            {
                var crudeFlightSegmentBusinessModel = new CrudeFlightSegmentModel();
                DataToModel(data, crudeFlightSegmentBusinessModel);
                list.Add(crudeFlightSegmentBusinessModel);
            }

            return(list);
        }
Ejemplo n.º 18
0
 // copy all columns from a SOAP Contract to a serialized data object
 // links:
 //  docLink: http://sql2x.org/documentationLink/10700d38-2227-4021-be12-2f4f206f5dd9
 public static void ContractToData(CrudeFlightSegmentContract contract, CrudeFlightSegmentData data)
 {
     data.FlightSegmentId       = contract.FlightSegmentId;
     data.FlightId              = contract.FlightId;
     data.DepartureAirportId    = contract.DepartureAirportId;
     data.ArrivalAirportId      = contract.ArrivalAirportId;
     data.LogicalSegmentNumber  = contract.LogicalSegmentNumber;
     data.PhysicalSegmentNumber = contract.PhysicalSegmentNumber;
     data.FromDateTime          = contract.FromDateTime;
     data.UntilDateTime         = contract.UntilDateTime;
     data.DepartureGate         = contract.DepartureGate;
     data.ArrivalGate           = contract.ArrivalGate;
     data.UserId   = contract.UserId;
     data.DateTime = contract.DateTime;
 }
Ejemplo n.º 19
0
 // copy all columns from a serialized data object to a SOAP Contract
 // links:
 //  docLink: http://sql2x.org/documentationLink/7553d6dd-da65-4a72-84c8-81f2f99ef4f5
 public static void DataToContract(CrudeFlightSegmentData data, CrudeFlightSegmentContract contract)
 {
     contract.FlightSegmentId       = data.FlightSegmentId;
     contract.FlightId              = data.FlightId;
     contract.DepartureAirportId    = data.DepartureAirportId;
     contract.ArrivalAirportId      = data.ArrivalAirportId;
     contract.LogicalSegmentNumber  = data.LogicalSegmentNumber;
     contract.PhysicalSegmentNumber = data.PhysicalSegmentNumber;
     contract.FromDateTime          = data.FromDateTime;
     contract.UntilDateTime         = data.UntilDateTime;
     contract.DepartureGate         = data.DepartureGate;
     contract.ArrivalGate           = data.ArrivalGate;
     contract.UserId   = data.UserId;
     contract.DateTime = data.DateTime;
 }
Ejemplo n.º 20
0
 // transfer data object to model object
 // links:
 //  docLink: http://sql2x.org/documentationLink/43d57600-5ff5-4ef8-9330-123773d100d3
 public static void DataToModel(CrudeFlightSegmentData data, CrudeFlightSegmentModel model)
 {
     model.FlightSegmentId       = data.FlightSegmentId;
     model.FlightId              = data.FlightId;
     model.DepartureAirportId    = data.DepartureAirportId;
     model.ArrivalAirportId      = data.ArrivalAirportId;
     model.LogicalSegmentNumber  = data.LogicalSegmentNumber;
     model.PhysicalSegmentNumber = data.PhysicalSegmentNumber;
     model.FromDateTime          = data.FromDateTime;
     model.UntilDateTime         = data.UntilDateTime;
     model.DepartureGate         = data.DepartureGate;
     model.ArrivalGate           = data.ArrivalGate;
     model.UserId   = data.UserId;
     model.DateTime = data.DateTime;
 }
Ejemplo n.º 21
0
 // transfer model object to data object
 // links:
 //  docLink: http://sql2x.org/documentationLink/95875d99-b7f7-4a9e-baa4-3fbe9925d8a2
 public static void ModelToData(CrudeFlightSegmentModel model, CrudeFlightSegmentData data)
 {
     data.FlightSegmentId       = model.FlightSegmentId;
     data.FlightId              = model.FlightId;
     data.DepartureAirportId    = model.DepartureAirportId;
     data.ArrivalAirportId      = model.ArrivalAirportId;
     data.LogicalSegmentNumber  = model.LogicalSegmentNumber;
     data.PhysicalSegmentNumber = model.PhysicalSegmentNumber;
     data.FromDateTime          = model.FromDateTime;
     data.UntilDateTime         = model.UntilDateTime;
     data.DepartureGate         = model.DepartureGate;
     data.ArrivalGate           = model.ArrivalGate;
     data.UserId   = model.UserId;
     data.DateTime = model.DateTime;
 }
Ejemplo n.º 22
0
        /// <summary>Create all flights based on schedule record</summary>
        /// <summary>Schedule main dates will be used if segments does not exist</summary>
        /// <summary>Identifiers are taken from schedule</summary>
        /// <summary>Segments are taken from schedule if existing, default segment created if not</summary>
        /// <summary>Flight and segment 'created' events inserted</summary>
        /// <summary>Action log event inserted, exceptions logged</summary>
        public void MakeFlightsFromSchedule(
            Guid flightScheduleId,
            Guid userId
            )
        {
            Logging.ActionLog("SolutionNorSolutionPort.BusinessLogicLayer.ScheduleService.MakeFlightsFromSchedule",
                              userId
                              );

            // get schedule
            ScheduleContract scheduleContract = GetSchedule(flightScheduleId, userId);

            // make sure there are segments
            if (scheduleContract.CrudeFlightScheduleSegments.Length == 0)
            {
                Logging.ErrorLog("Schedule",
                                 "ScheduleService",
                                 "MakeFlightsFromSchedule",
                                 "Schedule.MakeFlightsFromSchedule: There are no segments on schedule",
                                 string.Empty,
                                 userId
                                 );

                throw new Exception("Schedule.MakeFlightsFromSchedule: There are no segments on schedule");
            }

            // make sure there is at least one identifier
            if (scheduleContract.FlightScheduleIdentifier == null ||
                scheduleContract.FlightScheduleIdentifier.FlightScheduleIdentifierId == Guid.Empty)
            {
                Logging.ErrorLog("Schedule",
                                 "ScheduleService",
                                 "MakeFlightsFromSchedule",
                                 "Schedule.MakeFlightsFromSchedule: There are no flight identifiers",
                                 string.Empty,
                                 userId
                                 );

                throw new Exception("Schedule.MakeFlightsFromSchedule: There are no flight identifiers");
            }

            // get first aircraft available, TODO
            List <CrudeAircraftContract> aircrafts = new CrudeAircraftService().FetchAll();

            if (aircrafts.Count == 0)
            {
                Logging.ErrorLog("Schedule",
                                 "ScheduleService",
                                 "MakeFlightsFromSchedule",
                                 "Schedule.MakeFlightsFromSchedule: There are no aircrafts available",
                                 string.Empty,
                                 userId
                                 );

                throw new Exception("Schedule.MakeFlightsFromSchedule: There are no aircrafts available");
            }

            // start transaction
            using (var connection = new SqlConnection(Conn.ConnectionString)) {
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();

                try {
                    // iterate all dates between from / until
                    DateTime currentDate = scheduleContract.FlightSchedule.FromDateTime.Date;

                    while (currentDate >= scheduleContract.FlightSchedule.FromDateTime.Date &&
                           currentDate <= scheduleContract.FlightSchedule.UntilDateTime)
                    {
                        // make new flight
                        var flight = new CrudeFlightData();
                        flight.FlightId           = Guid.NewGuid();
                        flight.BindingFlightId    = flight.FlightId;
                        flight.AirlineId          = scheduleContract.FlightSchedule.AirlineId;
                        flight.AircraftId         = aircrafts[0].AircraftId;
                        flight.AircraftTypeRcd    = scheduleContract.FlightSchedule.AircraftTypeRcd;
                        flight.DepartureAirportId = scheduleContract.FlightSchedule.DepartureAirportId;
                        flight.ArrivalAirportId   = scheduleContract.FlightSchedule.ArrivalAirportId;

                        // compose flight date time departure / arrival time from first and last segment
                        // todo, what about day shift +-
                        flight.FromDateTime = currentDate.Add(
                            scheduleContract.FlightScheduleSegments[0].DepartureTime
                            );

                        flight.UntilDateTime = currentDate.Add(
                            scheduleContract.FlightScheduleSegments[scheduleContract.FlightScheduleSegments.Length - 1].ArrivalTime
                            );

                        flight.Comment  = scheduleContract.FlightSchedule.Comment;
                        flight.DateTime = DateTime.UtcNow;
                        flight.UserId   = userId;

                        // make sure flight does not exist
                        List <CrudeFlightData> flightDataList =
                            CrudeFlightData.FetchWithFilter(
                                flightId: Guid.Empty,
                                becameFlightId: Guid.Empty,
                                bindingFlightId: Guid.Empty,
                                airlineId: flight.AirlineId,
                                aircraftId: flight.AircraftId,
                                aircraftTypeRcd: string.Empty,
                                departureAirportId: flight.DepartureAirportId,
                                arrivalAirportId: flight.ArrivalAirportId,
                                fromDateTime: flight.FromDateTime,
                                untilDateTime: flight.UntilDateTime,
                                comment: string.Empty,
                                userId: Guid.Empty,
                                dateTime: DateTime.MinValue
                                );

                        if (flightDataList.Count != 0)
                        {
                            continue;
                        }

                        flight.Insert(connection, transaction);

                        // flight identifier
                        // todo, can be more than one
                        var identifier = new CrudeFlightIdentifierData();
                        identifier.FlightIdentifierTypeRcd = scheduleContract.FlightScheduleIdentifier.FlightIdentifierTypeRcd;
                        identifier.FlightIdentifierCode    = scheduleContract.FlightScheduleIdentifier.FlightIdentifierCode;
                        identifier.FlightId = flight.FlightId;
                        identifier.UserId   = userId;
                        identifier.DateTime = DateTime.UtcNow;
                        identifier.Insert(connection, transaction);

                        // events
                        AddFlightEvent(connection, transaction, flight.FlightId, DateTimeTypeRef.Created, DateTime.UtcNow, userId);

                        // planned / estimated times
                        AddFlightEvent(connection, transaction, flight.FlightId, DateTimeTypeRef.PlannedDeparture, flight.FromDateTime, userId);
                        AddFlightEvent(connection, transaction, flight.FlightId, DateTimeTypeRef.PlannedArrival, flight.UntilDateTime, userId);
                        AddFlightEvent(connection, transaction, flight.FlightId, DateTimeTypeRef.EstimatedDeparture, flight.FromDateTime, userId);
                        AddFlightEvent(connection, transaction, flight.FlightId, DateTimeTypeRef.EstimatedArrival, flight.UntilDateTime, userId);

                        // open for booking
                        AddFlightEvent(connection, transaction, flight.FlightId, DateTimeTypeRef.BookingOpen, DateTime.UtcNow, userId);

                        // check rules

                        // create flight segments for that day
                        foreach (CrudeFlightScheduleSegmentContract scheduleSegment in scheduleContract.CrudeFlightScheduleSegments)
                        {
                            var flightSegment = new CrudeFlightSegmentData();
                            flightSegment.FlightSegmentId       = Guid.NewGuid();
                            flightSegment.FlightId              = flight.FlightId;
                            flightSegment.DepartureAirportId    = scheduleSegment.DepartureAirportId;
                            flightSegment.ArrivalAirportId      = scheduleSegment.ArrivalAirportId;
                            flightSegment.LogicalSegmentNumber  = scheduleSegment.LogicalSegmentNumber;
                            flightSegment.PhysicalSegmentNumber = scheduleSegment.PhysicalSegmentNumber;
                            flightSegment.FromDateTime          = currentDate.Add(scheduleSegment.DepartureTime);
                            flightSegment.UntilDateTime         = currentDate.Add(scheduleSegment.ArrivalTime);
                            flightSegment.DepartureGate         = scheduleSegment.DepartureGate;
                            flightSegment.ArrivalGate           = scheduleSegment.ArrivalGate;
                            flightSegment.UserId   = userId;
                            flightSegment.DateTime = DateTime.UtcNow;
                            flightSegment.Insert(connection, transaction);

                            // events
                            AddFlightSegmentEvent(connection, transaction, flightSegment.FlightSegmentId, DateTimeTypeRef.Created, DateTime.UtcNow, userId);

                            // planned / estimated times
                            AddFlightSegmentEvent(connection, transaction, flightSegment.FlightSegmentId, DateTimeTypeRef.PlannedDeparture, flightSegment.FromDateTime, userId);
                            AddFlightSegmentEvent(connection, transaction, flightSegment.FlightSegmentId, DateTimeTypeRef.PlannedArrival, flightSegment.UntilDateTime, userId);
                            AddFlightSegmentEvent(connection, transaction, flightSegment.FlightSegmentId, DateTimeTypeRef.EstimatedDeparture, flightSegment.FromDateTime, userId);
                            AddFlightSegmentEvent(connection, transaction, flightSegment.FlightSegmentId, DateTimeTypeRef.EstimatedArrival, flightSegment.UntilDateTime, userId);

                            // open for booking
                            AddFlightSegmentEvent(connection, transaction, flightSegment.FlightSegmentId, DateTimeTypeRef.BookingOpen, DateTime.UtcNow, userId);
                        }

                        currentDate = currentDate.AddDays(1);

                        break; // break here since we are testing with a fresh database where from date is todays date
                    }

                    // commit transaction
                    transaction.Commit();
                } catch (Exception ex) {
                    transaction.Rollback();
                    Logging.ErrorLog("Schedule",
                                     "ScheduleService",
                                     "MakeFlightsFromSchedule",
                                     ex.Message,
                                     ex.StackTrace,
                                     userId
                                     );
                    throw ex;
                }
            }
        }
Ejemplo n.º 23
0
 // delete row
 // links:
 //  docLink: http://sql2x.org/documentationLink/59823bf7-4ad8-4684-a48b-2abd49c607ee
 public void Delete(System.Guid flightSegmentId)
 {
     CrudeFlightSegmentData.Delete(flightSegmentId);
 }
Ejemplo n.º 24
0
 // fetch by Search key into current object
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d
 // parameters:
 //  ArrivalAirportId: key of table CrudeFlightSegmentData
 public List <CrudeFlightSegmentModel> FetchByArrivalAirportId(System.Guid arrivalAirportId)
 {
     return(DataListToModelList(CrudeFlightSegmentData.FetchByArrivalAirportId(arrivalAirportId)));
 }
Ejemplo n.º 25
0
 // fetch by Foreign key into new List of class instances
 // links:
 //  docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e
 public List <CrudeFlightSegmentContract> FetchByUserId(System.Guid userId)
 {
     return(DataListToContractList(CrudeFlightSegmentData.FetchByUserId(userId)));
 }
Ejemplo n.º 26
0
 // get a count of rows in table
 // links:
 //  docLink: http://sql2x.org/documentationLink/39677f9e-daee-45c6-9527-da98a0d7958d
 public int FetchAllCount()
 {
     return(CrudeFlightSegmentData.FetchAllCount());
 }
Ejemplo n.º 27
0
 // fetch by Search key into current object
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d
 // parameters:
 //  DepartureAirportId: key of table CrudeFlightSegmentData
 public List <CrudeFlightSegmentModel> FetchByDepartureAirportId(System.Guid departureAirportId)
 {
     return(DataListToModelList(CrudeFlightSegmentData.FetchByDepartureAirportId(departureAirportId)));
 }
Ejemplo n.º 28
0
        public void UpdateFlight(
            FlightContract flightContract,
            Guid userId
            )
        {
            Logging.ActionLog("SolutionNorSolutionPort.BusinessLogicLayer.FlightService.UpdateFlight",
                              userId
                              );

            // start transaction
            using (var connection = new SqlConnection(Conn.ConnectionString)) {
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();

                try {
                    // insert new flight
                    var crudeNewFlightData = new CrudeFlightData();
                    CrudeFlightService.ContractToData(
                        flightContract.Flight,
                        crudeNewFlightData
                        );

                    crudeNewFlightData.FlightId = Guid.NewGuid();

                    // binding flight id carries on forward
                    crudeNewFlightData.BindingFlightId = flightContract.Flight.BindingFlightId;

                    crudeNewFlightData.UserId   = userId;
                    crudeNewFlightData.DateTime = DateTime.UtcNow;
                    crudeNewFlightData.Insert(connection, transaction);

                    // todo, can be more than one
                    if (!String.IsNullOrEmpty(flightContract.FlightIdentifier.FlightIdentifierCode))
                    {
                        var crudeNewFlightIdentifierData = new CrudeFlightIdentifierData();

                        CrudeFlightIdentifierService.ContractToData(
                            flightContract.FlightIdentifier,
                            crudeNewFlightIdentifierData
                            );

                        crudeNewFlightIdentifierData.FlightIdentifierId      = Guid.NewGuid();
                        crudeNewFlightIdentifierData.FlightId                = crudeNewFlightData.FlightId;
                        crudeNewFlightIdentifierData.FlightIdentifierTypeRcd = FlightIdentifierTypeRef.FlightNumberThree;
                        crudeNewFlightIdentifierData.DateTime                = DateTime.UtcNow;
                        crudeNewFlightIdentifierData.UserId = userId;
                        crudeNewFlightIdentifierData.Insert(connection, transaction);
                    }

                    // update old flight schedule 'became' identifier
                    var crudeOldFlightData = new CrudeFlightData();
                    crudeOldFlightData.FetchByFlightId(flightContract.Flight.FlightId);
                    crudeOldFlightData.BecameFlightId = crudeNewFlightData.FlightId;
                    crudeOldFlightData.Update(connection, transaction);

                    // copy segments
                    List <CrudeFlightSegmentData> crudeFlightSegmentsData =
                        CrudeFlightSegmentData.FetchByFlightId(
                            flightContract.Flight.FlightId
                            );

                    foreach (CrudeFlightSegmentData crudeFlightSegmentData in crudeFlightSegmentsData)
                    {
                        crudeFlightSegmentData.FlightSegmentId = Guid.NewGuid();
                        crudeFlightSegmentData.FlightId        = crudeNewFlightData.FlightId;
                        crudeFlightSegmentData.DateTime        = DateTime.UtcNow;
                        crudeFlightSegmentData.UserId          = userId;
                        crudeFlightSegmentData.Insert(connection, transaction);
                    }

                    // commit transaction
                    transaction.Commit();
                } catch (Exception ex) {
                    transaction.Rollback();

                    Logging.ErrorLog("Flight",
                                     "FlightService",
                                     "UpdateFlight",
                                     ex.Message,
                                     ex.StackTrace,
                                     userId
                                     );
                    throw ex;
                }
            }
        }
Ejemplo n.º 29
0
 // fetch by Search key into current object
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/87368fa6-b618-4f0c-acbb-1fc4e273bb2d
 // parameters:
 //  UserId: key of table CrudeFlightSegmentData
 public List <CrudeFlightSegmentModel> FetchByUserId(System.Guid userId)
 {
     return(DataListToModelList(CrudeFlightSegmentData.FetchByUserId(userId)));
 }
Ejemplo n.º 30
0
 // fetch by Foreign key into new List of class instances
 // links:
 //  docLink: http://sql2x.org/documentationLink/a7599485-4f00-4ebf-974d-53f69c43654e
 public List <CrudeFlightSegmentContract> FetchByArrivalAirportId(System.Guid arrivalAirportId)
 {
     return(DataListToContractList(CrudeFlightSegmentData.FetchByArrivalAirportId(arrivalAirportId)));
 }