Procedures
Procedures
Procedures
/
***********************************************************************************
**********************
*Procedure Name : USP_CreateCars
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Create Cars in traviyo backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_CreateCars
@ClientId BIGINT,
@Name VARCHAR(50),
@FromLocation VARCHAR(MAX),
@ToLocation VARCHAR(MAX),
@Price VARCHAR(MAX),
@Facilities VARCHAR(MAX),
@CreatedBy BIGINT,
@RecordStatusId BIGINT = 1,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT,
@CarId BIGINT OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO
Cars(ClientId,Name,FromLocation,ToLocation,Price,Facilities,CreatedOn,CreatedBy,Rec
ordStatusId)
VALUES(@ClientId,@Name,@FromLocation,@ToLocation,@Price,@Facilities,GETDATE(),@Crea
tedBy,@RecordStatusId)
SET @Success = 1
SET @Message = 'Cars Created Successfully.'
SET @CarId = SCOPE_IDENTITY()
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Cars Created Failed.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<-------------------------------------------
SHOW---------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_GetAllCars
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Get All Cars in traviyo backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
ALTER PROC USP_GetAllCars
@ClientId BIGINT,
@RecordStatusId BIGINT,
@Success BIGINT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
SELECT C.Id,C.ClientId,C.Name,CT.Name as
CarType,C.FromLocation,C.ToLocation,C.Price,C.Facilities,C.RecordStatusId FROM Cars
C
JOIN CarType CT on C.CarTypeId=CT.Id
WHERE ClientId=@ClientId
SET @Success = -1
SET @Message = 'Cars List Found.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Cars List Not Found.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<------------------------------EDIT--------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_GetCarById
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Get Car By Id in traviyo backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_GetCarById
@Id BIGINT,
@ClientId BIGINT,
@RecordStatusId BIGINT,
@Success BIGINT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
SELECT C.Id,C.ClientId,C.Name,C.CarTypeId as CarTypeId,CT.Name as
CarType,C.FromLocation,C.ToLocation,C.Price,C.Facilities,C.RecordStatusId FROM Cars
C
JOIN CarType CT on C.CarTypeId=CT.Id
WHERE C.Id=@Id AND C.ClientId=@ClientId
SET @Success = -1
SET @Message = 'Car Found.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Not Found.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<--------------------------------------
UPDATE---------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_UpdateCars
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Update Cars in traviyo backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_UpdateCars
@Id BIGINT,
@ClientId BIGINT,
@Name VARCHAR(50),
@FromLocation VARCHAR(MAX),
@ToLocation VARCHAR(MAX),
@Price VARCHAR(MAX),
@Facilities VARCHAR(MAX),
@UpdatedBy BIGINT,
@RecordStatusId BIGINT,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT,
@CarId BIGINT OUTPUT
AS
BEGIN
BEGIN TRANSACTION;
BEGIN TRY
UPDATE Cars SET
ClientId=@ClientId
,Name=@Name
,FromLocation=@FromLocation
,ToLocation=@ToLocation
,Price=@Price
,Facilities=@Facilities
,UpdatedOn=GETDATE()
,UpdatedBy=@UpdatedBy
,RecordStatusId=@RecordStatusId
WHERE Id=@Id AND RecordStatusId=@RecordStatusId
SET @Success = 1
SET @Message = 'Cars Updated Successfully.'
SET @CarId = SCOPE_IDENTITY()
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Cars Updated Failed.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION;
END
<------------------------------------------DELETE OR
RECOVER---------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_DeleteOrRecover
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Delete Or Recover Cars in traviyo
backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROCEDURE USP_DeleteOrRecover
(
@Id BIGINT,
@UpdatedBy BIGINT,
@RecordStatusId BIGINT,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
)
AS
BEGIN
DECLARE @ActiveRecordStatusId BIGINT
DECLARE @DeletedRecordStatusId BIGINT
select @ActiveRecordStatusId=Id from RecordStatus where Name='Active'
select @DeletedRecordStatusId=Id from RecordStatus where Name='Deleted'
IF EXISTS(SELECT TOP 1 Id FROM Cars WHERE Id = @Id)
BEGIN
IF(@RecordStatusId=@ActiveRecordStatusId)
BEGIN
UPDATE Cars
SET
RecordStatusId = @DeletedRecordStatusId,
UpdatedBy = @UpdatedBy,
UpdatedOn = GETUTCDATE()
WHERE Id = @Id
SET @Success = 1
SET @Message = 'Cars deleted successfully.'
END
ELSE
BEGIN
UPDATE Cars SET
RecordStatusId = @ActiveRecordStatusId,
UpdatedBy = @UpdatedBy,
UpdatedOn = GETUTCDATE()
WHERE Id = @Id
SET @Success = 1
SET @Message = 'Cars recovered successfully.'
END
END
ELSE
BEGIN
SET @Success = 0
SET @Message = 'Cars to delete Document.'
END
END
<------------------------------------CREATE CAR
INCLUSION--------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_CreateCarInclusion
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Create Car Inclusion in traviyo
backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
ALTER PROC USP_CreateCarInclusion
@CarId BIGINT,
@Name VARCHAR(100),
@CreatedBy BIGINT,
@RecordStatusId BIGINT,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO CarInclusion(CarId,Name,CreatedOn,CreatedBy,RecordStatusId)
VALUES(@CarId,@Name,GETUTCDATE(),@CreatedBy,@RecordStatusId)
SET @Success = 1
SET @Message = 'Car Inclusion Created Successfully.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Inclusion Created Failed.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<----------------------------------------EDIT CAR
INCLUSION----------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_GetCarInclusionByCarId
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Get Car By Id in traviyo backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_GetCarInclusionByCarId
@CarId BIGINT,
@RecordStatusId BIGINT,
@Success BIGINT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
SELECT CI.Id,CI.Name,CI.RecordStatusId FROM CarInclusion CI
WHERE CI.Id=@CarId AND RecordStatusId=@RecordStatusId
SET @Success = -1
SET @Message = 'Car Inclusion Found.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Inclusion Not Found.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<----------------------------------------DELETE CAR
INCLUSION----------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_DeleteCarInclusion
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Delete Car Inclusion in traviyo
backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_DeleteCarInclusion
@Id BIGINT,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
DELETE FROM CarInclusion WHERE Id=@Id
SET @Success = 1
SET @Message = 'Car Inclusion Deleted Successfully.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Inclusion Deleted Failed.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<------------------------------------------CREATE CAR
EXCLUSION--------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_CreateCarExclusion
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Create Car Exclusion in traviyo
backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
ALTER PROC USP_CreateCarExclusion
@CarId BIGINT,
@Name VARCHAR(100),
@CreatedBy BIGINT,
@RecordStatusId BIGINT,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO CarExclusion(CarId,Name,CreatedOn,CreatedBy,RecordStatusId)
VALUES(@CarId,@Name,GETUTCDATE(),@CreatedBy,@RecordStatusId)
SET @Success = 1
SET @Message = 'Car Exclusion Created Successfully.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Exclusion Created Failed.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<------------------------------------------DELETE CAR
EXCLUSION--------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_DeleteCarExclusion
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Delete Car Exclusion in traviyo
backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_DeleteCarExclusion
@Id BIGINT,
@Success BIT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
DELETE FROM CarExclusion WHERE Id=@Id
SET @Success = 1
SET @Message = 'Car Exclusion Deleted Successfully.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Exclusion Deleted Failed.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<------------------------------------------EDIT CAR
EXCLUSION--------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_GetCarExclusionByCarId
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Get Car Exclusions By Id in traviyo
backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
ALTER PROC USP_GetCarExclusionByCarId
@CarId BIGINT,
@RecordStatusId BIGINT,
@Success BIGINT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
SELECT CE.Id,CE.Name,CE.RecordStatusId FROM CarExclusion CE
WHERE CE.Id=@CarId AND RecordStatusId=@RecordStatusId
SET @Success = -1
SET @Message = 'Car Exclusion Found.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Exclusion Not Found.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END
<--------------------------------------------SHOW CAR
TYPE------------------------------------------------->
/
***********************************************************************************
**********************
*Procedure Name : USP_GetCarType
*Authore : Baijayanta(Rohit)
*Version : 1.0
*Organisation : Stoutweb.com
*Date : 30-10-2020
*Purpose : This Procedure is used to Get CarType in traviyo backend
-----------------------------------------------------------------------------------
-----------------------
Modified By | Modified On | Purpose
| |
***********************************************************************************
************************/
CREATE PROC USP_GetCarType
@ClientId BIGINT,
@RecordStatusId BIGINT,
@Success BIGINT OUTPUT,
@Message VARCHAR(MAX) OUTPUT
AS
BEGIN
BEGIN TRANSACTION
BEGIN TRY
SELECT CT.Id,CT.Name AS CarType FROM CarType CT
WHERE CT.Id=@ClientId AND RecordStatusId=@RecordStatusId
SET @Success = -1
SET @Message = 'Car Type Found.'
END TRY
BEGIN CATCH
SET @Success = -1
SET @Message = 'Car Type Not Found.'
ROLLBACK TRANSACTION
END CATCH
COMMIT TRANSACTION
END