// Sql Server Connector
        // TODO - Make the CreateTaxiCentral method actually save to the database
        /// <summary>
        /// Saves a new Taxi central to the database
        /// </summary>
        /// <param name="model">The Taxi central information</param>
        /// <returns>The Taxi Central information, including the unique identifier.</returns>
        public TaxiCentralModel CreateTaxiCentral(TaxiCentralModel model)
        {
            using (IDbConnection connection = new Microsoft.Data.SqlClient.SqlConnection(
                       GlobalConfig.GetConnectionString("TDMSDatabase")))
            {
                var p = new DynamicParameters();
                p.Add("@Name", model.Name);
                p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute("dbo.spTaxiCentral_Insert", p, commandType: CommandType.StoredProcedure);

                model.Id = p.Get <int>("@Id");

                return(model);
            }
        }
Exemple #2
0
 public void DeleteData(string sql, object parameters)
 {
     using IDbConnection cnn = new Microsoft.Data.SqlClient.SqlConnection(ConnectionString);
     cnn.Execute(sql, parameters);
 }