Exemple #1
0
        // 0 - success
        // 1 - different owner
        // 2 - tab not exist
        // 3 - username not exist
        // 4 - can't share yourselt
        // 5 - exception
        public int ShareTab(int tabid, string userName)
        {
            int result = -1;

            try
            {
                RSSDBDataContext dt = new RSSDBDataContext();

                var tabsToShare = dt.Tabs.Where(_tab => _tab.ID == tabid);

                if (tabsToShare.Count <Tab>() == 0)
                {
                    result = 2;
                }
                else
                {
                    var tabToShare = tabsToShare.Single();
                    if (tabToShare.UserID != GetCurrentUserID())
                    {
                        result = 1;
                    }
                    else
                    {
                        Share share = new Share();
                        share.TabID = tabToShare.ID;

                        var UsersToShare = dt.Accounts.Where(account => account.Username.CompareTo(userName) == 0);
                        if (UsersToShare.Count <Account>() == 0)
                        {
                            result = 3;
                        }
                        else
                        {
                            share.AccountID = UsersToShare.Single().ID;
                            if (share.AccountID == GetCurrentUserID())
                            {
                                result = 4;
                            }
                            else
                            {
                                var shares = dt.Shares.Where(_share => _share.TabID == tabid && (_share.AccountID == GetCurrentUserID() || _share.AccountID == share.AccountID));
                                if (shares.Count <Share>() == 0)
                                {
                                    dt.Shares.InsertOnSubmit(share);
                                    dt.SubmitChanges();
                                }

                                result = 0;
                            }
                        }
                    }
                }
            }
            catch
            {
                result = 3;
            }
            finally
            {
            }

            return(result);
        }
Exemple #2
0
 partial void UpdateShare(Share instance);
Exemple #3
0
 partial void DeleteShare(Share instance);
Exemple #4
0
 private void detach_Shares(Share entity)
 {
     this.SendPropertyChanging();
     entity.Account = null;
 }
Exemple #5
0
 partial void InsertShare(Share instance);
        public int ShareTab(int tabid, string userName)
        {
            int result = -1;

            try
            {
                RSSDBDataContext dt = new RSSDBDataContext();

                var tabsToShare = dt.Tabs.Where(_tab => _tab.ID == tabid);

                if (tabsToShare.Count<Tab>() == 0)
                    result = 2;
                else
                {
                    var tabToShare = tabsToShare.Single();
                    if (tabToShare.UserID != GetCurrentUserID())
                        result = 1;
                    else
                    {
                        Share share = new Share();
                        share.TabID = tabToShare.ID;

                        var UsersToShare = dt.Accounts.Where(account => account.Username.CompareTo(userName) == 0);
                        if (UsersToShare.Count<Account>() == 0)
                        {
                            result = 3;
                        }
                        else
                        {
                            share.AccountID = UsersToShare.Single().ID;
                            if (share.AccountID == GetCurrentUserID())
                                result = 4;
                            else
                            {
                                var shares = dt.Shares.Where(_share => _share.TabID == tabid && (_share.AccountID == GetCurrentUserID() || _share.AccountID == share.AccountID));
                                if (shares.Count<Share>() == 0)
                                {
                                    dt.Shares.InsertOnSubmit(share);
                                    dt.SubmitChanges();
                                }

                                result = 0;
                            }
                        }

                    }
                }

            }
            catch
            {
                result = 3;
            }
            finally
            {
            }

            return result;
        }
Exemple #7
0
 private void attach_Shares(Share entity)
 {
     this.SendPropertyChanging();
     entity.Account = this;
 }
 partial void DeleteShare(Share instance);
 partial void UpdateShare(Share instance);
 partial void InsertShare(Share instance);
		private void detach_Shares(Share entity)
		{
			this.SendPropertyChanging();
			entity.Account = null;
		}
		private void attach_Shares(Share entity)
		{
			this.SendPropertyChanging();
			entity.Account = this;
		}