MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

HOW TO DISPLAY NOTIFICATIONS WHEN USER HAS UNREAD MESSAGES  (Mono Support )

Viewed 73585 time(s), 20 post(s) 01.08.2014 19:00:34by ZaeVega

Related topics

amrmagdy

amrmagdy

23.12.2014 00:50:36
Please
Where I can add this code?

I get this error:
"MonoSoftware.MonoX.Repositories.MessageRepository' does not contain a definition for 'GetInstance"
Dieser Inhalt wurde noch nicht bewertet. 
127 Reputation 15 Total posts
imarusic

imarusic

23.12.2014 08:22:11
Hi,

can you please let us know what MonoX version you have?

Regards.
Dieser Inhalt wurde noch nicht bewertet. 
3016 Reputation 428 Total posts
amrmagdy

amrmagdy

23.12.2014 13:25:13

MonoX v5.1.40.5030 [31/10/2014], DB v4.7.3842

Dieser Inhalt wurde noch nicht bewertet. 
127 Reputation 15 Total posts
imarusic

imarusic

23.12.2014 13:36:54
Hi,

you need to use DI in order to get an instance  for the Message repository:

DependencyInjectionFactory.Resolve<IMessageRepository>().GetNumberOfUnreadMessages(userId);
Regards.
Dieser Inhalt wurde noch nicht bewertet. 
3016 Reputation 428 Total posts
amrmagdy

amrmagdy

23.12.2014 13:50:58
error CS0103: The name 'DependencyInjectionFactory' does not exist in the current context

full code is :
<asp:PlaceHolder runat="server" ID="plhNumber"><br><span class='number'><%= DependencyInjectionFactory.Resolve<IMessageRepository>().GetNumberOfUnreadMessages(userId) %></span></asp:PlaceHolder
Dieser Inhalt wurde noch nicht bewertet. 
127 Reputation 15 Total posts
imarusic

imarusic

23.12.2014 14:32:08
Just tried on the "SeoLoginStatus" control which has "DependencyInjectionFactory" property inherited from the BaseUserControl and it works.

Also, you need include repository import in your markup:

<%@ Import Namespace="MonoSoftware.MonoX.Repositories" %>

Bewertet mit 5,00, 1 Besucher. 
3016 Reputation 428 Total posts
amrmagdy

amrmagdy

23.12.2014 14:50:38
"SeoLoginStatus" control code now is
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SeoLoginStatus.ascx.cs"
    Inherits="MonoSoftware.MonoX.Controls.SeoLoginStatus" %>
    <%@ Import Namespace="MonoSoftware.MonoX.Repositories" %>
 
<asp:PlaceHolder ID="panStatus" runat="server">
    <asp:LinkButton runat="server" ID="btnButton">
        <span class="icon-logout"><%= LogoutText %></span>       
    </asp:LinkButton>
    <asp:HyperLink runat="server" ID="btnLink"><%= LoginText %></asp:HyperLink>
</asp:PlaceHolder>
 
<asp:PlaceHolder runat="server" ID="plhNumber">
<span class='number'><%= DependencyInjectionFactory.Resolve<IMessageRepository>().GetNumberOfUnreadMessages(userId) %></span>
 
 
</asp:PlaceHolder>
But I get this error:
error CS0103: The name 'userId' does not exist in the current context
Dieser Inhalt wurde noch nicht bewertet. 
127 Reputation 15 Total posts
imarusic

imarusic

23.12.2014 14:55:58
"userId" was just a hint that you need provide "GetNumberOfUnreadMessages" with the required parameters.

UserId can be obtained as I wrote in the topic marked as answered:

SecurityUtility.GetUserId();
It returns current logged user's id.

Regards.
Bewertet mit 5,00, 1 Besucher. 
3016 Reputation 428 Total posts
amrmagdy

amrmagdy

23.12.2014 15:21:32
Thank you &  I'm sorry it's my mistake  :)
Dieser Inhalt wurde noch nicht bewertet. 
127 Reputation 15 Total posts
imarusic

imarusic

23.12.2014 15:23:42
No problem, we are glad that you managed to implement it.

Regards.
Dieser Inhalt wurde noch nicht bewertet. 
3016 Reputation 428 Total posts
1 2