public static void deleteNotification(User user, Notifications msg)
        {
            if (String.Compare(user.UserID, msg.Receiver, true) != 0)
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, You cannot delete message not in your inbox"));

            DAL dalDataContext = new DAL();
            try
            {
                Notifications matchingNotif = (from notif in dalDataContext.notifications
                                               where notif.Sender == msg.Sender &&
                                               notif.Receiver == user.UserID &&
                                               notif.SendDateTime == msg.SendDateTime
                                               select notif).Single<Notifications>();

                dalDataContext.notifications.DeleteOnSubmit(matchingNotif);
                dalDataContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(),
                  new FaultReason(ex.Message));
            }
        }
 public frmViewNotification(Notifications n, User u)
     : this()
 {
     this.note = n;
     this.user = u;
 }
Exemple #3
0
 public void SetNotificationRead(User user, Notifications msg)
 {
     NotificationController.setToRead(user, msg);
 }
Exemple #4
0
 public void DeleteNotifications(User user, Notifications msg)
 {
     NotificationController.deleteNotification(user, msg);
 }
        public static void setToRead(User user, Notifications msg)
        {
            if (String.Compare(user.UserID, msg.Receiver, true) != 0)
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, You cannot read messages not in your inbox"));

            DAL dalDataContext = new DAL();
            try
            {
                Notifications n1 = (from notifs in dalDataContext.notifications
                                    where notifs.Sender == msg.Sender &&
                                    notifs.Receiver == user.UserID &&
                                    notifs.SendDateTime == msg.SendDateTime
                                    select notifs).SingleOrDefault();
                n1.isRead = true;
                dalDataContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(),
                  new FaultReason(ex.Message));
            }
        }
        public static void sendNotification(string sender, string receiver, string title, string msg)
        {
            DAL dalDataContext = new DAL();
            Table<Notifications> noti = dalDataContext.notifications;

            Notifications newMsg = new Notifications(sender, receiver, title, msg);
            noti.InsertOnSubmit(newMsg);
            noti.Context.SubmitChanges();
        }