Example #1
0
        public void ReplacePhone(int businessEntityId, PhoneInfo oldPhone, PhoneInfo newPhone)
        {
            Auth.ThrowFaultExceptionIfNotAuthenticated();
            ValidateNonNegative(businessEntityId, nameof(businessEntityId));
            oldPhone.Validate();
            newPhone.Validate();

            DoSql(@"SET XACT_ABORT ON;

BEGIN TRANSACTION

    DELETE FROM [Person].[PersonPhone]
    WHERE BusinessEntityID = @customerBusinessEntityId
        AND PhoneNumber = @oldPhone
        AND PhoneNumberTypeID = @oldPhoneType

    INSERT INTO [Person].[PersonPhone]
			    ([BusinessEntityID]
			    ,[PhoneNumber]
                ,[PhoneNumberTypeID])
		    VALUES
			    (@customerBusinessEntityId
			    ,@newPhone
                ,@newPhoneType)

COMMIT",
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@customerBusinessEntityId", SqlDbType.Int), businessEntityId),
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@oldPhone", SqlDbType.NVarChar, 25), oldPhone.PhoneNumber),
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@oldPhoneType", SqlDbType.Int), oldPhone.PhoneNumberTypeId),
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@newPhone", SqlDbType.NVarChar, 25), newPhone.PhoneNumber),
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@newPhoneType", SqlDbType.Int), newPhone.PhoneNumberTypeId)
                  );
        }
Example #2
0
        public void CreatePhoneAndAssociateWithCustomer(int businessEntityId, PhoneInfo toCreate)
        {
            Auth.ThrowFaultExceptionIfNotAuthenticated();
            ValidateNonNegative(businessEntityId, nameof(businessEntityId));
            toCreate.Validate();

            DoSql(@"SET XACT_ABORT ON;

BEGIN TRANSACTION

    INSERT INTO [Person].[PersonPhone]
			    ([BusinessEntityID]
			    ,[PhoneNumber]
                ,[PhoneNumberTypeID])
		    VALUES
			    (@customerBusinessEntityId
			    ,@newPhone
                ,@newPhoneType)

COMMIT",
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@customerBusinessEntityId", SqlDbType.Int), businessEntityId),
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@newPhone", SqlDbType.NVarChar, 25), toCreate.PhoneNumber),
                  new KeyValuePair <SqlParameter, object>(new SqlParameter("@newPhoneType", SqlDbType.Int), toCreate.PhoneNumberTypeId)
                  );
        }