[dbo].[MssWebGetOrderUnreadAndScheduledCount]
CREATE procedure [dbo].[MssWebGetOrderUnreadAndScheduledCount]
@inOrderId int,
@inSysUserId int
as
begin
set nocount on
declare @subscribedOnly bit = 0;
select
UnreadCount = isnull(Sum(ContactMessagesCount.UpdateCount),0) ,
ScheduledCount = isnull(Sum(ContactMessagesCount.ScheduledMessageCount),0)
from [dbo].udfGetUnreadAndScheduledMessageCount(@inSysUserId,@subscribedOnly) ContactMessagesCount
inner join SakariContact on ContactMessagesCount.ContactID = SakariContact.SakariContactID
left outer join SakariContactOrderMap on ContactMessagesCount.ContactID = SakariContactOrderMap.SakariContactFID
inner join SakariAccount on SakariContact.SakariAccountFID = SakariAccount.SakariAccountID
inner join Orders on SakariContactOrderMap.OrderFID = Orders.PriKey
where SakariContactOrderMap.OrderFID = @inOrderId
end
GO
GRANT EXECUTE ON [dbo].[MssWebGetOrderUnreadAndScheduledCount] TO [MssExec]
GO