public void Delete(Message Message)
 {
     using (DbManager dbm = new DbManager())
     {
         Accessor.Query.Delete(dbm, Message);
     }
 }
 protected void btnOMessageOK_Click(object sender, EventArgs e)
 {
     UsersClass userAccount = (UsersClass)Session["USER_ACCOUNT"];
     Message message = new Message();
     List<Message> Messages = MSGManager.GetMessagesToday(DateTime.Today, userAccount.ID);
     message = Messages.FirstOrDefault();
     message.Status = "READ";
     MSGManager.Save(message);
 }
 public void Save(Message Message)
 {
     using (DbManager db = new DbManager())
     {
         if (Message.RecordNumber != 0)
         {
             Accessor.Query.Update(db, Message);
         }
         else
         {
             Accessor.Query.Insert(db, Message);
         }
     }
 }
 protected void btnSend_Click(object sender, EventArgs e)
 {
     long ToUser = long.Parse(Request.QueryString["UserID"]);
     long FromUser = Permission.PERMITTED_USER.ID;
     MSG = new Message
     {
         DateSent = DateTime.UtcNow,
         FromUserId = FromUser ,
         Status = "UNREAD",
         MessageContent = messageEditor.Content,
         Subject = txtSubject .Text,
         ToUserId = ToUser
     };
     MSGManager.Save(MSG);
     hfMessageSent_ModalPopupExtender.Show();
 }
 protected void btnOMessageOK_Click(object sender, EventArgs e)
 {
     try
     {
         UsersClass userAccount = (UsersClass)Session["USER_ACCOUNT"];
         Message message = new Message();
         List<Message> Messages = MSGManager.GetMessagesToday(DateTime.Today, userAccount.ID);
         message = Messages.FirstOrDefault();
         message.Status = "READ";
         MSGManager.Save(message);
         btnNewMessage.Visible = false;
     }
     catch (Exception)
     {
         Redirector.Redirect("~/Marketing/DashBoardPanel.aspx");
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         try
         {
             UsersClass userAccount = (UsersClass)Session["USER_ACCOUNT"];
             Messages = MSGManager.GetMessagesToday(DateTime.Today, userAccount.ID);
             if (Messages.Count > 1)
             {
                 foreach (Message msg in Messages)
                 {
                     string from = "FROM: " + UserManager.GetUserAccountByKey(msg.FromUserId).Username + "<br />" + msg.MessageContent;
                     msg.MessageContent = from;
                 }
                 this.gvMessages.DataSource = Messages;
                 gvMessages.DataBind();
             }
             else
             {
                 message = Messages.FirstOrDefault();
            //     lblFrom.Text = UserManager.GetUserAccountByKey(message.FromUserId).Username;
         //        string from = lblFrom.Text + "<br />" + message.MessageContent;
          //       message.MessageContent = from;
              //   LiteralControl objPanelText = pnlMessageContent.Controls[0] as LiteralControl;
             //    objPanelText.Text = message.MessageContent;
              //   message.Status = "READ";
              //   MSGManager.Save(message);
             }
         }
         catch (Exception)
         {
             Redirector.Redirect("~/Marketing/DashBoardPanel.aspx");
         }
     }
 }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["USER_ACCOUNT"] != null)
            {
                UsersClass userAccount = (UsersClass)Session["USER_ACCOUNT"];
                Permission.PERMITTED_USER = userAccount;
                if (!Permission.IsAdmin())
                {
                    hpLinkAdmin.Visible = false;
                }
                if(string.IsNullOrEmpty(userAccount.FullName)){
                    lblName.Text = userAccount.Username;
                }else{
                    lblName.Text = userAccount.FullName;
                }
                if (string.IsNullOrEmpty(userAccount.Avatar))
                {
                   if(userAccount.Gender !="Male"){
                       imgAvatar.ImageUrl = "~/Marketing/Marketing-Admin/user-images/femaleicon.png";
                   }
                   else
                   {
                       imgAvatar.ImageUrl = "~/Marketing/Marketing-Admin/user-images/maleicon.png";
                   }
                }
                else
                {
                    imgAvatar.ImageUrl = "~/Marketing/Marketing-Admin/user-images/"+userAccount.Avatar;
                }
                 List <Message> Messages = MSGManager.GetMessagesToday(DateTime.Today,userAccount.ID);
                if (Messages.Count >0)
                {
                    msgNotification.Visible = true;
                    int msg_count = Messages.Count;
                    if (msg_count > 1)
                    {
                        hpLinkNewMessage.Visible = true;
                        hpLinkNewMessage.Text = Messages.Count + "New Messages";
                        btnNewMessage.Visible = false;
                    }
                    else
                    {

                        btnNewMessage.Visible = true;
                        Message message = new Message();
                        message = Messages.FirstOrDefault();
                        UsersClass fromUser = UserManager.GetUserAccountByKey(message.FromUserId);
                        LiteralControl objPanelText = pnlMsgContent.Controls[0] as LiteralControl;
                        if (!string.IsNullOrEmpty(fromUser.FullName))
                        {
                            objPanelText.Text = "FROM:" + fromUser.FullName + "<br />" + message.MessageContent;
                        }
                        else
                        {
                            objPanelText.Text = "FROM:" + fromUser.Username + "<br />" + message.MessageContent ;
                        }
                        hpLinkNewMessage.Visible = false;
                    }
                    Session["MESSAGES"] = Messages;
                    hpLinkNewMessage.NavigateUrl = "~/Marketing/ViewMessage.aspx";
                }
                else
                {
                    msgNotification.Visible = false;
                }
            }
            else
            {
                Redirector.Redirect("~/Marketing/SessionExpired.aspx");
            }
        }