Thursday, 19 October 2017

Feed Back Ratings Scaler Valued Function

ALTER FUNCTION [dbo].[UserFeedBackRatings]
(
@Rating DECIMAL(18,1)
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @RatingsImg NVARCHAR(max);
SET  @RatingsImg  = (CASE WHEN @Rating = '0.5' THEN '<i class="fa fa-star-half" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '1.0' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '1.5' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-half" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '2.0' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '2.5' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-half" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '3.0' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '3.5' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-half" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '4.0' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-o" aria-hidden="true"></i>'
WHEN @Rating = '4.5' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star-half" aria-hidden="true"></i>'
WHEN @Rating = '5.0' THEN '<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'+'&nbsp;'+'<i class="fa fa-star" aria-hidden="true"></i>'
END)

RETURN @RatingsImg

END

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...