Пример #1
0
        // Get one poline based on its POLineID (SQL Select)
        // This only works if you're already created the stored procedure.
        public async Task <POLine> POLine_GetOne(int @POLineID)
        {
            POLine poline     = new POLine();
            var    parameters = new DynamicParameters();

            parameters.Add("@POLineID", POLineID, DbType.Int32);
            using (var conn = new SqlConnection(_configuration.Value))
            {
                poline = await conn.QueryFirstOrDefaultAsync <POLine>("spPOLine_GetOne", parameters, commandType : CommandType.StoredProcedure);
            }
            return(poline);
        }
Пример #2
0
        // Add (create) a POLine table row (SQL Insert)
        // This only works if you're already created the stored procedure.
        public async Task <bool> POLineInsert(POLine poline)
        {
            using (var conn = new SqlConnection(_configuration.Value))
            {
                var parameters = new DynamicParameters();
                parameters.Add("POLineHeaderID", poline.POLineHeaderID, DbType.Int32);
                parameters.Add("POLineProductID", poline.POLineProductID, DbType.Int32);
                parameters.Add("POLineProductDescription", poline.POLineProductDescription, DbType.String);
                parameters.Add("POLineProductQuantity", poline.POLineProductQuantity, DbType.Decimal);
                parameters.Add("POLineProductUnitPrice", poline.POLineProductUnitPrice, DbType.Decimal);
                parameters.Add("POLineTaxRate", poline.POLineTaxRate, DbType.Decimal);
                parameters.Add("POLineTaxID", poline.POLineTaxID, DbType.Decimal);

                // Stored procedure method
                await conn.ExecuteAsync("spPOLine_Insert", parameters, commandType : CommandType.StoredProcedure);
            }
            return(true);
        }