public override int CreateOrUpdate(TransitAccountGroupAccountRequest t_instance, ManagedSecurityContext sec)
        {
            ManagedAccountGroup m_group = new ManagedAccountGroup(Session, t_instance.AccountGroupId);

            if (m_group.HasAccountRequest(t_instance.AccountId))
            {
                throw new Exception(string.Format(
                                        "You already have a membership request pending to join \"{0}\".", m_group.Instance.Name));
            }

            if (m_group.HasAccount(t_instance.AccountId))
            {
                throw new Exception(string.Format(
                                        "You are already a member of \"{0}\".", m_group.Instance.Name));
            }

            int id = base.CreateOrUpdate(t_instance, sec);

            Session.Flush();

            foreach (AccountGroupAccount accountadmin in Collection <AccountGroupAccount> .GetSafeCollection(mInstance.AccountGroup.AccountGroupAccounts))
            {
                if (accountadmin.IsAdministrator)
                {
                    ManagedAccount recepient = new ManagedAccount(Session, accountadmin.Account.Id);
                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                        Session, recepient, string.Format("EmailAccountGroupAccountRequest.aspx?id={0}", id));
                }
            }

            return(id);
        }
        public void Accept(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.AllExceptUpdate);

            ManagedAccountGroup group = new ManagedAccountGroup(Session, mInstance.AccountGroup);

            if (!group.HasAccount(mInstance.Requester.Id))
            {
                Session.Delete(mInstance);

                throw new Exception(string.Format("Sorry, {0} is no longer member of \"{2}\".",
                                                  mInstance.Requester.Name));
            }

            // account may already a member (invited twice by different admins, etc.)
            if (!group.HasAccount(mInstance.Account.Id))
            {
                JoinGroup(sec, message);

                ManagedAccount recepient = new ManagedAccount(Session, mInstance.Requester);
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                    Session,
                    recepient,
                    string.Format("EmailAccountGroupAccountInvitationAccept.aspx?id={0}&aid={1}&message={2}",
                                  this.Id, sec.Account.Id, Renderer.UrlEncode(message)));
            }

            Session.Delete(mInstance);
        }
        public void Reject(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.Update);

            Account requester = mInstance.Account;
            Account approver  = mInstance.Keen;

            if (!string.IsNullOrEmpty(message))
            {
                ManagedAccount recepient = new ManagedAccount(Session, requester);
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, recepient,
                                                                          string.Format("EmailAccountFriendRequestReject.aspx?id={0}&message={1}", this.Id, Renderer.UrlEncode(message)));

                // delete the request when user notified
                Collection <AccountFriendRequest> .GetSafeCollection(mInstance.Account.AccountFriendRequests).Remove(mInstance);

                Session.Delete(mInstance);
            }
            else
            {
                // silently reject the request
                mInstance.Rejected = true;
                Session.Save(mInstance);
            }
        }
 public void Send()
 {
     ManagedSiteConnector.SendAccountEmailMessageUriAsAdmin(
         Session,
         mInstance.Email,
         string.Format("EmailAccountInvitation.aspx?id={0}", mInstance.Id));
 }
 public void Send()
 {
     ManagedSiteConnector.SendAccountEmailMessageUriAsAdmin(
         Session,
         new MailAddress(mInstance.AccountEmail.Address, mInstance.AccountEmail.Account.Name).ToString(),
         string.Format("EmailAccountEmailVerify.aspx?id={0}", mInstance.Id));
 }
示例#6
0
        protected override void Save(ManagedSecurityContext sec)
        {
            bool fNew = (mInstance.Id == 0);

            if (mInstance.Id == 0)
            {
                mInstance.Sent = DateTime.UtcNow;
            }

            base.Save(sec);

            Session.Flush();

            if (fNew)
            {
                ManagedAccount recepient = new ManagedAccount(Session, mInstance.RecepientAccountId);
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                    Session, recepient, string.Format("EmailAccountMessage.aspx?id={0}", mInstance.Id));

                // save a copy in Sent items
                AccountMessage copy = new AccountMessage();
                copy.Account = Session.Load <Account>(mInstance.SenderAccountId);
                copy.AccountMessageFolder = ManagedAccountMessageFolder.FindRootFolder(Session, mInstance.SenderAccountId, "sent");
                copy.Body = mInstance.Body;
                copy.RecepientAccountId = mInstance.RecepientAccountId;
                copy.SenderAccountId    = mInstance.SenderAccountId;
                copy.Sent    = mInstance.Sent;
                copy.Subject = mInstance.Subject;
                copy.Unread  = true;
                Session.Save(copy);
            }
        }
示例#7
0
        public void Accept(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.Delete);

            AccountPlace place = new AccountPlace();

            place.Account     = mInstance.Account;
            place.Place       = mInstance.Place;
            place.Created     = place.Modified = DateTime.UtcNow;
            place.Type        = mInstance.Type;
            place.Description = string.Format("System-approved on {0}.", DateTime.UtcNow.ToString());
            Session.Save(place);

            if (mInstance.Account.AccountPlaces == null)
            {
                mInstance.Account.AccountPlaces = new List <AccountPlace>();
            }
            mInstance.Account.AccountPlaces.Add(place);

            if (mInstance.Place.AccountPlaces == null)
            {
                mInstance.Place.AccountPlaces = new List <AccountPlace>();
            }
            mInstance.Place.AccountPlaces.Add(place);

            ManagedAccount recepient = new ManagedAccount(Session, mInstance.Account);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, recepient,
                                                                      string.Format("EmailAccountPlaceRequestAccept.aspx?id={0}&message={1}", this.Id, Renderer.UrlEncode(message)));

            // delete the request when user notified
            Collection <AccountPlaceRequest> .GetSafeCollection(mInstance.Account.AccountPlaceRequests).Remove(mInstance);

            Session.Delete(mInstance);
        }
        public override int CreateOrUpdate(TransitAccountGroupAccountInvitation t_instance, ManagedSecurityContext sec)
        {
            ManagedAccountGroup m_group   = new ManagedAccountGroup(Session, t_instance.AccountGroupId);
            ManagedAccount      m_account = new ManagedAccount(Session, t_instance.AccountId);

            if (m_group.HasAccountInvitation(t_instance.AccountId) || m_group.HasAccountRequest(t_instance.AccountId))
            {
                throw new Exception(string.Format("An invitation for {0} to join \"{1}\" is already pending.",
                                                  m_account.Instance.Name, m_group.Instance.Name));
            }

            if (m_group.HasAccount(t_instance.AccountId))
            {
                throw new Exception(string.Format("{0} is already a member of \"{1}\".",
                                                  m_account.Name, m_group.Instance.Name));
            }

            int id = base.CreateOrUpdate(t_instance, sec);

            Session.Flush();

            ManagedAccount recepient = new ManagedAccount(Session, t_instance.AccountId);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                Session, recepient, string.Format("EmailAccountGroupAccountInvitation.aspx?id={0}", id));

            return(id);
        }
示例#9
0
        public override void Delete(ManagedSecurityContext sec)
        {
            string         uri   = string.Format("EmailPlaceChangeRequestDeleted.aspx?id={0}", mInstance.Id);
            ManagedAccount owner = new ManagedAccount(Session, mInstance.Account);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, owner, uri);
            base.Delete(sec);
        }
示例#10
0
        public override int CreateOrUpdate(TransitDiscussionPost t_instance, ManagedSecurityContext sec)
        {
            Nullable <DateTime> lastModified = new Nullable <DateTime>();

            if (mInstance != null)
            {
                lastModified = mInstance.Modified;
            }

            // discussion admin can update stickyness
            bool fStickyModified = false;

            if (mInstance != null && mInstance.Sticky != t_instance.Sticky)
            {
                fStickyModified = true;
            }
            if (mInstance == null && t_instance.Sticky)
            {
                fStickyModified = true;
            }
            if (fStickyModified)
            {
                ManagedDiscussion m_discussion = new ManagedDiscussion(Session, mInstance != null
                    ? mInstance.DiscussionThread.Discussion.Id
                    : t_instance.DiscussionId);
                m_discussion.GetACL().Check(sec, DataOperation.Update);
            }

            int id = base.CreateOrUpdate(t_instance, sec);

            try
            {
                ManagedAccount ra = new ManagedAccount(Session, mInstance.AccountId);
                ManagedAccount ma = new ManagedAccount(Session, mInstance.DiscussionPostParent != null
                    ? mInstance.DiscussionPostParent.AccountId
                    : mInstance.DiscussionThread.Discussion.Account.Id);

                // if the author is editing the post, don't notify within 30 minute periods
                if (ra.Id != ma.Id && (t_instance.Id == 0 ||
                                       (lastModified.HasValue && lastModified.Value.AddMinutes(30) > DateTime.UtcNow)))
                {
                    Session.Flush();

                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                        Session, ma, string.Format("EmailDiscussionPost.aspx?id={0}", mInstance.Id));
                }
            }
            catch (ObjectNotFoundException)
            {
                // replying to an account that does not exist
            }

            return(id);
        }
        public void Reject(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.AllExceptUpdate);

            ManagedAccount recepient = new ManagedAccount(Session, mInstance.Requester);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, recepient,
                                                                      string.Format("EmailAccountGroupAccountInvitationReject.aspx?id={0}&aid={1}&message={2}",
                                                                                    this.Id, sec.Account.Id, Renderer.UrlEncode(message)));

            Session.Delete(mInstance);
        }
示例#12
0
        private RssFeed GetFeed()
        {
            string content = ManagedSiteConnector.GetHttpContentAsUser(
                Session, mInstance.Account.Id, mInstance.Url);
            RssFeed feed = RssFeed.Read(new StringReader(content));

            if (feed.Channels.Count == 0)
            {
                throw new Exception(string.Format(
                                        "Missing RSS channel in '{0}'.", mInstance.Url));
            }
            return(feed);
        }
示例#13
0
        public override int CreateOrUpdate(TransitAccountPlaceRequest t_instance, ManagedSecurityContext sec)
        {
            if (t_instance.Id == 0)
            {
                AccountPlace e_place = (AccountPlace)Session.CreateCriteria(typeof(AccountPlace))
                                       .Add(Expression.Eq("Account.Id", t_instance.AccountId))
                                       .Add(Expression.Eq("Place.Id", t_instance.PlaceId))
                                       .UniqueResult();

                if (e_place != null)
                {
                    throw new Exception(string.Format("You are already {0} of this place.",
                                                      Renderer.Render(e_place.Type.Name)));
                }

                AccountPlaceRequest e_placerequest = (AccountPlaceRequest)Session.CreateCriteria(typeof(AccountPlaceRequest))
                                                     .Add(Expression.Eq("Account.Id", t_instance.AccountId))
                                                     .Add(Expression.Eq("Place.Id", t_instance.PlaceId))
                                                     .UniqueResult();

                if (e_placerequest != null)
                {
                    throw new Exception(string.Format("You have already requested to be {0} of this place. Please be patient.",
                                                      Renderer.Render(e_placerequest.Type.Name)));
                }
            }

            int id = base.CreateOrUpdate(t_instance, sec);

            Session.Flush();

            ManagedSiteConnector.SendAccountEmailMessageUriAsAdmin(
                Session,
                new MailAddress(ManagedConfiguration.GetValue(Session, "SnCore.Admin.EmailAddress", "*****@*****.**"),
                                ManagedConfiguration.GetValue(Session, "SnCore.Admin.Name", "Admin")).ToString(),
                string.Format("EmailAccountPlaceRequest.aspx?id={0}", id));

            foreach (AccountPlace place in Collection <AccountPlace> .GetSafeCollection(mInstance.Place.AccountPlaces))
            {
                if (place.Type.CanWrite)
                {
                    ManagedAccount acct = new ManagedAccount(Session, place.Account);
                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                        Session, acct,
                        string.Format("EmailAccountPlaceRequest.aspx?id={0}", id));
                }
            }

            return(id);
        }
示例#14
0
 private void CheckQuota(TransitType t_instance, ManagedSecurityContext sec)
 {
     try
     {
         Check(t_instance, sec);
     }
     catch (ManagedAccount.QuotaExceededException)
     {
         ManagedAccount admin = new ManagedAccount(Session, ManagedAccount.GetAdminAccount(Session));
         ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
             Session, admin,
             string.Format("EmailAccountQuotaExceeded.aspx?id={0}", sec.Account.Id));
         throw;
     }
 }
示例#15
0
        public void Notify(ManagedSecurityContext sec)
        {
            IList <Account> owners = GetOwners();

            foreach (Account acct in owners)
            {
                if (sec.Account != null && sec.Account.Id != acct.Id)
                {
                    ManagedAccount m_acct = new ManagedAccount(Session, acct);
                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                        Session, m_acct,
                        string.Format("EmailPlacePicture.aspx?id={0}", mInstance.Id));
                }
            }
        }
示例#16
0
        public void Reject(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.Delete);

            ManagedAccount recepient = new ManagedAccount(Session, mInstance.Account);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                Session, recepient,
                string.Format("EmailAccountPlaceRequestReject.aspx?id={0}&message={1}", this.Id, Renderer.UrlEncode(message)));

            // delete the request when user notified
            Collection <AccountPlaceRequest> .GetSafeCollection(mInstance.Account.AccountPlaceRequests).Remove(mInstance);

            Session.Delete(mInstance);
        }
        public void Accept(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.Update);

            TransitAccountFriend t_friend = new TransitAccountFriend();

            t_friend.FriendId  = mInstance.Keen.Id;
            t_friend.AccountId = Instance.Account.Id;
            ManagedAccountFriend m_friend = new ManagedAccountFriend(Session);

            m_friend.CreateOrUpdate(t_friend, sec);

            ManagedAccount requester = new ManagedAccount(Session, mInstance.Account);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                Session,
                requester,
                string.Format("EmailAccountFriendRequestAccept.aspx?id={0}&message={1}", this.Id, Renderer.UrlEncode(message)));

            Session.Delete(mInstance);

            // delete a reciproque request if any
            AccountFriendRequest rr = (AccountFriendRequest)Session.CreateCriteria(typeof(AccountFriendRequest))
                                      .Add(Expression.Eq("Account.Id", mInstance.Keen.Id))
                                      .Add(Expression.Eq("Keen.Id", mInstance.Account.Id))
                                      .UniqueResult();

            if (rr != null)
            {
                Session.Delete(rr);
            }

            Collection <AccountFriendRequest> .GetSafeCollection(mInstance.Account.AccountFriendRequests).Remove(mInstance);

            if (m_friend.Instance.Account.AccountFriends == null)
            {
                m_friend.Instance.Account.AccountFriends = new List <AccountFriend>();
            }
            m_friend.Instance.Account.AccountFriends.Add(m_friend.Instance);

            if (m_friend.Instance.Keen.AccountFriends == null)
            {
                m_friend.Instance.Keen.AccountFriends = new List <AccountFriend>();
            }
            m_friend.Instance.Keen.AccountFriends.Add(m_friend.Instance);
        }
示例#18
0
        protected override void Save(ManagedSecurityContext sec)
        {
            bool fNew = (mInstance.Id == 0);

            if (fNew)
            {
                mInstance.Created = DateTime.UtcNow;
            }
            base.Save(sec);

            if (fNew)
            {
                ManagedAccount admin = new ManagedAccount(Session, ManagedAccount.GetAdminAccount(Session));
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, admin,
                                                                          string.Format("EmailAccountFlag.aspx?id={0}", mInstance.Id));
            }
        }
示例#19
0
        public override int CreateOrUpdate(TransitBug t_instance, ManagedSecurityContext sec)
        {
            base.CreateOrUpdate(t_instance, sec);

            if (t_instance.Id == 0)
            {
                ManagedAccount admin = new ManagedAccount(Session, ManagedAccount.GetAdminAccount(Session));

                if (admin.Id != mInstance.AccountId)
                {
                    Session.Flush();

                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                        Session, admin,
                        string.Format("EmailBugCreated.aspx?id={0}", mInstance.Id));
                }
            }

            return(mInstance.Id);
        }
        public void Accept(ManagedSecurityContext sec, string message)
        {
            GetACL().Check(sec, DataOperation.AllExceptUpdate);

            AccountGroupAccount account = new AccountGroupAccount();

            account.Account      = mInstance.Account;
            account.AccountGroup = mInstance.AccountGroup;
            account.Created      = account.Modified = DateTime.UtcNow;
            Session.Save(account);

            ManagedAccount recepient = new ManagedAccount(Session, account.Account);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                Session,
                recepient,
                string.Format("EmailAccountGroupAccountRequestAccept.aspx?id={0}&aid={1}&message={2}",
                              this.Id, sec.Account.Id, Renderer.UrlEncode(message)));

            Session.Delete(mInstance);
        }
示例#21
0
        protected override void Save(ManagedSecurityContext sec)
        {
            bool fNew = (mInstance.Id == 0);

            mInstance.Modified = DateTime.UtcNow;
            if (mInstance.Id == 0)
            {
                mInstance.Created = mInstance.Modified;
            }
            base.Save(sec);

            if (fNew)
            {
                Session.Flush();

                ManagedAccount acct = new ManagedAccount(Session, mInstance.Account);

                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                    Session, acct, string.Format("EmailRefererAccount.aspx?id={0}", mInstance.Id));
            }
        }
示例#22
0
        public override int CreateOrUpdate(TransitMadLibInstance t_instance, ManagedSecurityContext sec)
        {
            Nullable <DateTime> lastModified = new Nullable <DateTime>();

            if (mInstance != null)
            {
                lastModified = mInstance.Modified;
            }
            int id = base.CreateOrUpdate(t_instance, sec);

            if (t_instance.ObjectAccountId == 0)
            {
                return(id);
            }

            try
            {
                ManagedAccount ra = new ManagedAccount(Session, t_instance.AccountId);
                ManagedAccount ma = new ManagedAccount(Session, t_instance.ObjectAccountId);

                // if the author is editing the post, don't notify within 30 minute periods
                if (ra.Id != ma.Id && (t_instance.Id == 0 ||
                                       (lastModified.HasValue && lastModified.Value.AddMinutes(30) > DateTime.UtcNow)))
                {
                    Session.Flush();

                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, ma,
                                                                              string.Format("EmailAccountMadLibInstance.aspx?aid={0}&ObjectName={1}&oid={2}&mid={3}&id={4}&ReturnUrl={5}",
                                                                                            t_instance.ObjectAccountId, mInstance.DataObject.Name, mInstance.ObjectId,
                                                                                            mInstance.MadLib.Id, mInstance.Id, Renderer.UrlEncode(t_instance.ObjectUri)));
                }
            }
            catch (ObjectNotFoundException)
            {
                // replying to an account that does not exist
            }

            return(id);
        }
示例#23
0
        protected override void Save(ManagedSecurityContext sec)
        {
            bool fNew = (mInstance.Id == 0);

            if (mInstance.Id == 0)
            {
                mInstance.Created = DateTime.UtcNow;
            }
            base.Save(sec);

            if (fNew)
            {
                Session.Flush();

                IEnumerable <Account> accounts = GetInstanceAccounts();
                foreach (Account account in accounts)
                {
                    ManagedAccount acct = new ManagedAccount(Session, account);
                    ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(
                        Session, acct, string.Format("EmailFeature.aspx?id={0}&aid={1}", mInstance.Id, acct.Id));
                }
            }
        }
示例#24
0
        public void Close(ManagedSecurityContext sec)
        {
            switch (mInstance.Status.Name)
            {
            case "Resolved":
                break;

            default:
                throw new InvalidOperationException();
            }

            mInstance.Status = ManagedBugStatus.Find(Session, "Closed");
            Save(sec);

            // notify that the bug has been closed, account may not exist any more

            Session.Flush();

            ManagedAccount acct = new ManagedAccount(Session, mInstance.AccountId);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, acct,
                                                                      string.Format("EmailBugClosed.aspx?id={0}", mInstance.Id));
        }
示例#25
0
        public override int CreateOrUpdate(TransitPlaceChangeRequest t_instance, ManagedSecurityContext sec)
        {
            int id = base.CreateOrUpdate(t_instance, sec);

            Session.Flush();

            if (t_instance.Id == 0)
            {
                string         uri   = string.Format("EmailPlaceChangeRequestCreated.aspx?id={0}", id);
                ManagedAccount owner = new ManagedAccount(Session, mInstance.Place.Account);
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, owner, uri);

                foreach (AccountPlace place in Collection <AccountPlace> .GetSafeCollection(mInstance.Place.AccountPlaces))
                {
                    if (place.Type.CanWrite)
                    {
                        ManagedAccount acct = new ManagedAccount(Session, place.Account);
                        ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, acct, uri);
                    }
                }
            }

            return(id);
        }
示例#26
0
        public override int CreateOrUpdate(TransitAccountGroupAccount t_instance, ManagedSecurityContext sec)
        {
            ManagedAccountGroup m_group = new ManagedAccountGroup(Session, t_instance.AccountGroupId);

            // check whether the user is already a member
            if (t_instance.Id == 0 && m_group.HasAccount(t_instance.AccountId))
            {
                throw new Exception(string.Format(
                                        "You are already a member of \"{0}\".", m_group.Instance.Name));
            }

            // ensure that user isn't trying to self promote
            if (t_instance.Id > 0 && t_instance.IsAdministrator)
            {
                // the caller isn't a group admin
                if (!m_group.HasAdministratorAccount(sec.Account.Id))
                {
                    throw new ManagedAccount.AccessDeniedException();
                }
            }

            // ensure that not removing last admin
            if (t_instance.Id > 0 && !t_instance.IsAdministrator)
            {
                AccountGroupAccount existing_instance = Session.Load <AccountGroupAccount>(t_instance.Id);
                if (existing_instance.IsAdministrator)
                {
                    bool fHasAnotherAdmin = false;
                    foreach (AccountGroupAccount instance in existing_instance.AccountGroup.AccountGroupAccounts)
                    {
                        if (instance.IsAdministrator && instance != existing_instance)
                        {
                            fHasAnotherAdmin = true;
                            break;
                        }
                    }

                    if (!fHasAnotherAdmin)
                    {
                        throw new Exception("Cannot demote the last group administrator.");
                    }
                }
            }

            int id = base.CreateOrUpdate(t_instance, sec);

            if (t_instance.Id == 0)
            {
                if (mInstance.AccountGroup.AccountGroupAccounts == null)
                {
                    mInstance.AccountGroup.AccountGroupAccounts = new List <AccountGroupAccount>();
                }
                mInstance.AccountGroup.AccountGroupAccounts.Add(mInstance);

                // subscribe the user to a group feed
                TransitAccountRssWatch t_watch = new TransitAccountRssWatch();
                t_watch.UpdateFrequency = 24;
                t_watch.Name            = mInstance.AccountGroup.Name;
                t_watch.Url             = string.Format("AccountGroupRss.aspx?id={0}", mInstance.AccountGroup.Id);
                t_watch.Enabled         = true;
                t_watch.AccountId       = mInstance.Account.Id;
                ManagedAccountRssWatch m_watch = new ManagedAccountRssWatch(Session);
                m_watch.CreateOrUpdate(t_watch, ManagedAccount.GetUserSecurityContext(Session, mInstance.Account.Id));
                Session.Flush();

                // e-mail the user a welcome message
                ManagedAccount recepient = new ManagedAccount(Session, mInstance.Account);
                ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, recepient,
                                                                          string.Format("EmailAccountGroupAccount.aspx?id={0}",
                                                                                        id));
            }

            return(id);
        }