Beispiel #1
0
        public void SetProjectNotification(ProjectNotification notif, int projectId, bool enable)
        {
            if ((notif & ProjectNotification.OwnerNotificationMask) != 0)
            {
                ValidateProject(projectId);
            }

            if ((notif & ProjectNotification.AdminNotificationMask) != 0)
            {
                CheckIsAdmin();
            }

            UserProject up = db.SelectObject <UserProject> ("SELECT * FROM UserProject WHERE UserId={0} AND ProjectId={1}", user.Id, projectId);

            if (enable)
            {
                if (up == null)
                {
                    up = new UserProject()
                    {
                        UserId = user.Id, ProjectId = projectId, Notifications = notif
                    };
                    db.InsertObject <UserProject> (up);
                }
                else
                {
                    up.Notifications |= notif;
                    db.UpdateObject(up);
                }
            }
            else if (up != null)
            {
                up.Notifications &= ~notif;
                db.UpdateObject(up);
            }
        }