Exemple #1
0
        /// <summary>
        /// edit a contract
        /// </summary>
        /// <param name="taxiRestaurantContract">object of taxiRestaurantContract</param>
        /// <returns>object of taxiRestaurantContract</returns>
        public TaxiRestaurantContract EditContract(TaxiRestaurantContract taxiRestaurantContract)
        {
            Database db        = Database.Open(DatabaseName);
            var      dbCommand = "UPDATE TaxiRestaurantContract SET (ContractDescription = @1) WHERE Id = @0";

            db.QuerySingle(dbCommand, taxiRestaurantContract.Id, taxiRestaurantContract.ContractDescription);
            db.Close();
            return(taxiRestaurantContract);
        }
Exemple #2
0
        /// <summary>
        /// gets a contract by id
        /// </summary>
        /// <param name="Id">id</param>
        /// <returns>contract</returns>
        public TaxiRestaurantContract GetContract(int Id)
        {
            Database db            = Database.Open(DatabaseName);
            string   insertCommand = "SELECT * FROM TaxiRestaurantContract WHERE Id = @0";
            var      row           = db.QuerySingle(insertCommand, Id);

            db.Close();
            if (row == null)
            {
                return(null);
            }
            TaxiRestaurantContract contract = new TaxiRestaurantContract(row.Id, row.RestaurantId, row.TaxiCompanyId, row.ContractDescription);

            return(contract);
        }
Exemple #3
0
        /// <summary>
        /// gets all contracts from a taxi company
        /// </summary>
        /// <param name="TaxiCompanyId">id</param>
        /// <returns>list of contracts</returns>
        public List <TaxiRestaurantContract> GetContractsFromTaxiCompany(int TaxiCompanyId)
        {
            Database db            = Database.Open(DatabaseName);
            string   insertCommand = "SELECT * FROM TaxiRestaurantContract WHERE TaxiCompanyId = @0";
            var      rows          = db.Query(insertCommand, TaxiCompanyId);

            db.Close();

            List <TaxiRestaurantContract> contracten = new List <TaxiRestaurantContract>();

            foreach (var row in rows)
            {
                TaxiRestaurantContract contract = new TaxiRestaurantContract(row.Id, row.RestaurantId,
                                                                             row.TaxiCompanyId, row.ContractDescription);
                contracten.Add(contract);
            }

            return(contracten);
        }