USP_DATAFORMTEMPLATE_ADD_ASSIGNMENT

The save procedure used by the add dataform template "Assignment Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@COURSEID uniqueidentifier IN Course
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@NAME nvarchar(20) IN Name
@DESCRIPTION nvarchar(255) IN Description
@MAXPOINTS int IN Max points
@CLASSASSIGNMENTS xml IN Select class sections that will share this assignment

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_ASSIGNMENT
(
    @ID uniqueidentifier = null output,
    @COURSEID uniqueidentifier = null,
    @CHANGEAGENTID uniqueidentifier = null,
    @NAME nvarchar(20) = '',
    @DESCRIPTION nvarchar(255) = '',
    @MAXPOINTS int = 0,
    @CLASSASSIGNMENTS xml = null
)
as

set nocount on;

if @ID is null
    set @ID = newid()

if @CHANGEAGENTID is null  
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()

begin try
    -- handle inserting the data

    insert into dbo.ASSIGNMENT
        (ID, NAME, DESCRIPTION, MAXPOINTS, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
    values
        (@ID, @NAME, @DESCRIPTION, COALESCE(@MAXPOINTS,0), @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE)

    -- link assignment to specified classes

    exec dbo.USP_GETCLASSASSIGNMENT_ADDFROMXML @ID, @CLASSASSIGNMENTS, @CHANGEAGENTID;
end try

begin catch
    exec dbo.USP_RAISE_ERROR
    return 1
end catch

return 0