 	UpdatedDate datetime,
 	ModifiedBy varchar(3),
 	Active bit,
-	PositionIntro varchar(2000),
+	PositionIntro varchar(400),
 	StatusID int DEFAULT ((1)) NOT NULL,
 	CancellationPolicyID int,
 	additionalinfo1 nvarchar(500),

END CATCH
 
 
;

-- =============================================
-- Author:		Iago Lorenzo Salgueiro
-- Create date: 2012-12-28
-- Description:	Changes the state of a Booking
-- Request and clean related no need records
-- in a safety way, to don't allow orphans
-- records.
-- Based on the code initially created on 
-- LcData.Booking.cs.
-- Be careful with the passed StatusID, is not
-- checked to be one of the valid 'invalid
-- request' statuses.
-- =============================================
CREATE PROCEDURE InvalidateBookingRequest
	@BookingRequestID int
	,@BookingRequestStatusID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	DECLARE @AddressID int

    BEGIN TRY
        BEGIN TRAN

        -- Get Service Address ID to be (maybe) removed later
        SELECT  @AddressID = AddressID
        FROM    BookingRequest
        WHERE   BookingRequestID = @BookingRequestID

        -- Removing CalendarEvents:
        DELETE FROM CalendarEvents
        WHERE ID IN (
            SELECT TOP 1 PreferredDateID FROM BookingRequest
            WHERE BookingRequestID = @BookingRequestID
            UNION
            SELECT TOP 1 AlternativeDate1ID FROM BookingRequest
            WHERE BookingRequestID = @BookingRequestID
            UNION
            SELECT TOP 1 AlternativeDate2ID FROM BookingRequest
            WHERE BookingRequestID = @BookingRequestID
        )

        /*
         * Updating Booking Request status, and removing references to the 
         * user selected dates.
         */
        UPDATE  BookingRequest
        SET     BookingRequestStatusID = @BookingRequestStatusID,
                PreferredDateID = null,
                AlternativeDate1ID = null,
                AlternativeDate2ID = null,
                AddressID = null,
                UpdatedDate = getdate()
        WHERE   BookingRequestID = @BookingRequestID

        -- Removing Service Address, if is not an user saved location (it has not AddressName)
        DELETE FROM ServiceAddress
        WHERE AddressID = @AddressID
              AND (SELECT count(*) FROM Address As A WHERE A.AddressID = @AddressID AND AddressName is null) = 1
        DELETE FROM Address
        WHERE AddressID = @AddressID
               AND
              AddressName is null

        COMMIT TRAN

        -- We return sucessful operation with Error=0
        SELECT 0 As Error
		RETURN 0
    END TRY
    BEGIN CATCH
        IF @@TRANCOUNT > 0
            ROLLBACK TRAN
        -- We return error number and message
        DECLARE @error int
        SET @error = ERROR_NUMBER()
        SELECT @error As Error, ERROR_MESSAGE() As ErrorMessage
        RETURN @error
    END CATCH
END
;



;


CREATE PROCEDURE [dbo].[TestAlertPricingDetails]
	@UserID int,
	@PositionID int
AS
BEGIN
	
	
	SET NOCOUNT ON;
	DECLARE @AlertID int
	SET @AlertID = 1
    
    
    IF	dbo.fxCheckAlertAffectsUser(@UserID, @AlertID) = 0 OR
		
		(SELECT count(*) FROM userprofilepositions WHERE UserID=@UserID AND PositionID=@PositionID) = 0 OR
		
		
		EXISTS (SELECT * FROM ProviderPackage
			WHERE ProviderUserID = @UserID
				AND PositionID = @PositionID
