---FETCH BASED ON ID
CREATE PROCEDURE SP_APPLICANT_FETCH
	 (
	@id varchar(50)
	)
AS
BEGIN
	SELECT * from [TimeAndCo].[dbo].[ProjectClosureTasks] where id=@id
END
GO

---DELETE BASED ON ID
CREATE PROCEDURE SP_APPLICANT_DELETE
	 (
	@id varchar(50)
	)
AS
BEGIN
	DELETE FROM [TimeAndCo].[dbo].[ProjectClosureTasks] where id=@id;
END
GO

---INSERT SP
CREATE PROCEDURE SP_APPLICANT_SAVEN
	 (
		@id varchar(50),
		@org_id varchar(50),
		@projectId varchar(50),
		@tskName varchar(50),
		@remarks varchar(50),
		@status_id varchar(50),
		@assignRoleId varchar(50),
		@lvlOneAprvr varchar(50),
		@islvloneApprvd varchar(50),
		@lvlTwoAprvr varchar(50),
		@islvltwoApprvd varchar(50),
		@apprvlStatus varchar(50),
		@createdDate datetime,
		@modifiedDate datetime,
		@createdByEmpId varchar(50),
		@createdBy varchar(50),
		@isDeleted bit
	)
AS
BEGIN

	IF (SELECT TOP (1) 1 FROM [TimeAndCo].[dbo].[ProjectClosureTasks] WHERE id = @id) IS NULL
	INSERT INTO [TimeAndCo].[dbo].[ProjectClosureTasks]  (id, org_id, projectId, tskName, remarks, status_id, assignRoleId, lvlOneAprvr,islvloneApprvd, lvlTwoAprvr ,islvltwoApprvd, apprvlStatus, createdDate ,  modifiedDate ,createdByEmpId,createdBy,isDeleted)
		VALUES (@id, @org_id, @projectId, @tskName, @remarks, @status_id, @assignRoleId, @lvlOneAprvr, @islvloneApprvd, @lvlTwoAprvr , @islvltwoApprvd, @apprvlStatus, @createdDate ,  @modifiedDate , @createdByEmpId, @createdBy, @isDeleted);
	ELSE
	UPDATE [TimeAndCo].[dbo].[ProjectClosureTasks] SET projectId = @projectId , tskName =@tskName , remarks=@remarks , status_id=@status_id, assignRoleId=@assignRoleId, lvlOneAprvr =@lvlOneAprvr,islvloneApprvd=@islvloneApprvd,lvlTwoAprvr=@lvlTwoAprvr,islvltwoApprvd=@islvltwoApprvd,apprvlStatus=@apprvlStatus,createdDate=@createdDate,modifiedDate=@modifiedDate,createdByEmpId=@createdByEmpId,createdBy=@createdBy,isDeleted=@isDeleted
	  WHERE id = @id
END
GO