public CustomerContractsModel GetById(long customerId)
        {
            CustomerModel customer;

            using (_context)
            {
                customer = _context.Customer.FirstOrDefault(x => x.Id == customerId);
            }

            return(customer == null ? null : ModelConverterHelper.GetContractModel(customer));
        }
        public GateContractsModel GetById(long gateId)
        {
            if (gateId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(gateId));
            }

            using (_context)
            {
                this._gate = this._context.Gate.FirstOrDefault(x => x.Id == gateId);
            }

            return(this._gate == null ? null : ModelConverterHelper.GetContractModel(this._gate));
        }
        public bool Add(CustomerContractsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            using (_context)
            {
                this._customer = ModelConverterHelper.GetModelFromContract(model);
                this._context.Customer.Add(this._customer);
            }

            return(true);
        }
        public List <CustomerContractsModel> GetAllCustomers()
        {
            List <CustomerContractsModel> customerList = new List <CustomerContractsModel>();

            using (_context)
            {
                var customers = _context.Customer.ToList();

                foreach (var customer in customers)
                {
                    customerList.Add(ModelConverterHelper.GetContractModel(customer));
                }
            }

            return(customerList);
        }
        public List <FlightContractsModel> GetAllFlights()
        {
            List <FlightContractsModel> flightContracts = new List <FlightContractsModel>();

            using (_context)
            {
                IEnumerable <FlightModel> flights = _context.Flight.ToList();

                foreach (var flightModel in flights)
                {
                    flightContracts.Add(ModelConverterHelper.GetContractModel(flightModel));
                }
            }

            return(flightContracts);
        }
        public bool Add(FlightContractsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            using (_context)
            {
                this._flight = ModelConverterHelper.GetModelFromContract(model);
                this._context.Flight.Add(_flight);
                this._context.SaveChanges();
            }

            return(true);
        }
        public bool Save(FlightContractsModel flight)
        {
            if (flight == null)
            {
                throw new ArgumentNullException(nameof(flight));
            }

            using (_context)
            {
                this._flight = this._context.Flight.FirstOrDefault(x => x.Id == flight.Id);
                this._flight = ModelConverterHelper.GetModelFromContract(flight);
                this._context.SaveChanges();
            }

            return(true);
        }
        public bool Save(GateContractsModel gate)
        {
            if (gate == null)
            {
                throw new ArgumentNullException(nameof(gate));
            }

            using (_context)
            {
                this._gate = this._context.Gate.FirstOrDefault(x => x.Id == gate.Id);
                this._gate = ModelConverterHelper.GetModelFromContract(gate);
                this._context.SaveChanges();
            }

            return(true);
        }
        public List <GateContractsModel> GetAllGates()
        {
            List <GateContractsModel> gates = new List <GateContractsModel>();

            using (_context)
            {
                List <GateModel> gateModels = this._context.Gate.ToList();

                foreach (GateModel model in gateModels)
                {
                    gates.Add(ModelConverterHelper.GetContractModel(model));
                }
            }

            return(gates);
        }
        public bool Save(CustomerContractsModel customer)
        {
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }

            this._customer = ModelConverterHelper.GetModelFromContract(customer);

            using (_context)
            {
                var customerModel = _context.Customer.FirstOrDefault(x => x.Id == this._customer.Id);
                customerModel = _customer;
                _context.SaveChanges();
            }

            return(true);
        }
        public FlightContractsModel GetFlightById(long flightId)
        {
            if (flightId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(flightId));
            }

            using (_context)
            {
                this._flight = this._context.Flight.FirstOrDefault(x => x.Id == flightId);

                if (this._flight == null)
                {
                    return(null);
                }
            }

            return(ModelConverterHelper.GetContractModel(this._flight));
        }