コード例 #1
0
ファイル: Database.cs プロジェクト: vasiloreshenski/RFID
        /// <summary>
        /// Inserts access point if does not exists or updates it by identifier. If any of the provided values is null the column won't be updated
        /// </summary>
        /// <param name="identifier">identifier of the access point</param>
        /// <param name="transaction">transaction</param>
        /// <param name="description">description of the access point</param>
        /// <param name="IsActive">is active flag</param>
        /// <param name="accessLevel">access level of the access point</param>
        /// <returns></returns>
        public async Task <InsertOrUpdDbResult> InsertAccessPointIfNotExistsAsync(
            String serialNumber,
            IDbTransaction transaction,
            String description,
            bool IsActive,
            AccessLevel accessLevel,
            AccessPointDirectionType direction)
        {
            var param = new DynamicParameters(new { serial_number = serialNumber, description = description, is_active = IsActive, level_id = accessLevel, direction_id = direction });

            param.AddIdentity();

            var isInserted = await transaction.ExecuteStoreProcedureAsync <bool>("access_control.usp_insert_access_point_if_not_exists", param : param);

            return(InsertOrUpdDbResult.Create(param.Identity(), isInserted, false));
        }