Example #1
0
        public void AddComment(Comment c)
        {
            alert = new Alert();
            alert.CreateDate = c.CreateDate;
            if (c.SystemObjectID == 1)
            {
                _statusUpdateRepository = new StatusUpdateRepository();
                StatusUpdate st = _statusUpdateRepository.GetStatusUpdateByID((int)c.SystemObjectRecordID);
                account=_accountRepository.GetAccountByID(st.SenderID);
                alertMessage = GetProfileUrl(c.CommentByUsername)+" bình luận status của "+ GetProfileUrl(account.UserName)+":" + c.Body;
                alert.Message = alertMessage;
                alert.AccountID = c.CommentByAccountID;
                alert.AlertTypeID = (int)AlertType.AlertTypes.Comment;
                SaveAlert(alert);

                Notification notification = new Notification();
                string notify = "<a href=\"/UserProfile2.aspx?AccountID=" + c.CommentByAccountID.ToString() + "\">" +
                c.CommentByUsername + "</a>" +
                 "vừa mới bình luận status của bạn: " + c.Body;
                notification.AccountID = st.SenderID;
                notification.CreateDate = c.CreateDate;
                notification.IsRead =false;
                notification.Body = notify;
                _notifycationRepository.SaveNotification(notification);
            }
        }
Example #2
0
 public AlertService()
 {
     _userSession = new UserSession();
     _alertRepository = new AlertRepository();
     _webContext = new WebContext();
     alert = new Alert();
 }
Example #3
0
 public void DeleteAlert(Alert alert)
 {
     using (SPKTDataContext spktDC = conn.GetContext())
     {
         spktDC.Alerts.DeleteOnSubmit(alert);
         spktDC.SubmitChanges();
     }
 }
Example #4
0
 public AlertService()
 {
     _userSession = new UserSession();
     _alertRepository = new AlertRepository();
     _webContext = new WebContext();
     _friendRepository = new FriendRepository();
     alert = new Alert();
     _accountRepository = new AccountRepository();
     _groupMemberRepository = new GroupMemberRepository();
     _notifycationRepository = new NotificationRepository();
 }
Example #5
0
 public void AddNewBlogPostAlert(Blog blog)
 {
     alert = new Alert();
     alert.CreateDate = DateTime.Now;
     alert.AccountID = _userSession.CurrentUser.AccountID;
     alert.AlertTypeID = (int)AlertType.AlertTypes.NewBlogPost;
     alertMessage = "<div class=\"AlertHeader\">" + GetProfileImage(_userSession.CurrentUser.AccountID) +
                    GetProfileUrl(_userSession.CurrentUser.UserName) + " has just added a new blog post: <b>" +
                    blog.Title + "</b></div>";
     alert.Message = alertMessage;
     SaveAlert(alert);
     SendAlertToFriends(alert);
 }
Example #6
0
 public void SaveAlert(Alert alert)
 {
     using (SPKTDataContext spktDC = conn.GetContext())
     {
         if (alert.AlertID > 0)
         {
             spktDC.Alerts.Attach(alert, true);
         }
         else
         {
             alert.CreateDate = DateTime.Now;
             spktDC.Alerts.InsertOnSubmit(alert);
         }
         spktDC.SubmitChanges();
     }
 }
Example #7
0
 private void SendAlertToGroup(Alert alert, Group group)
 {
     List<int> groupMembers = _groupMemberRepository.GetMemberAccountIDsByGroupID(group.GroupID);
     foreach (int id in groupMembers)
     {
         alert.AlertID = 0;
         alert.AccountID = id;
         SaveAlert(alert);
         notify.AccountID = alert.AccountID;
         notify.Body = alert.Message;
         notify.IsRead = false;
         _notifycationRepository.SaveNotification(notify);
     }
 }
Example #8
0
 private void SendAlertToFriends(Alert alert)
 {
     List<Friend> friends = _friendRepository.GetFriendsByAccountID(alert.AccountID);
     foreach (Friend friend in friends)
     {
         alert.AlertID = 0;
         alert.AccountID = friend.MyFriendAccountID;
         SaveAlert(alert);
     }
 }
Example #9
0
 private void SaveAlert(Alert alert)
 {
     _alertRepository.SaveAlert(alert);
 }
Example #10
0
 private void Init()
 {
     account = _userSession.CurrentUser;
     alert = new Alert();
     alert.AccountID = account.AccountID;
     alert.CreateDate = DateTime.Now;
     notify = new Notification();
 }
Example #11
0
		private void detach_Alerts(Alert entity)
		{
			this.SendPropertyChanging();
			entity.Account = null;
		}
Example #12
0
		private void attach_Alerts(Alert entity)
		{
			this.SendPropertyChanging();
			entity.Account = this;
		}
Example #13
0
 partial void DeleteAlert(Alert instance);
Example #14
0
 partial void UpdateAlert(Alert instance);
Example #15
0
 partial void InsertAlert(Alert instance);
Example #16
0
 public void AddUpdatedBlogPostAlert(Blog blog)
 {
     Init();
     alert = new Alert();
     alert.CreateDate = DateTime.Now;
     alert.AccountID = _userSession.CurrentUser.AccountID;
     alert.AlertTypeID = (int)AlertType.AlertTypes.NewBlogPost;
     alertMessage = "<div >" + GetProfileImage(_userSession.CurrentUser.AccountID) +
                    GetProfileUrl(_userSession.CurrentUser.UserName) + " vừa mới cập nhật <b>" + "<a href=\"" + _webContext.RootUrl + "Blogs/ViewBlog" + ".aspx?BlogID=" + blog.BlogID + "\">" +
                    blog.Title + "</a>" +
                    "!</div>";
     alert.Message = alertMessage;
     SaveAlert(alert);
     SendAlertToFriends(alert);
 }