示例#1
0
 private void AddBoardThree(int? uplineId, BoardTwo user, Position? position)
 {
     Context.BoardThree.Add(new BoardThree()
     {
         ClientUserId = user.ClientUserId,
         DateCreated = DateTime.UtcNow.AddHours(8),
         Finished = false,
         Position = position,
         UplineUserId = uplineId
     });
 }
示例#2
0
        private bool VerifyToBoard(BoardThree board, BoardTwo attachThis)
        {
            //2
            var level1Left = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == board.ClientUserId && p.Position == Position.Left);
            if (level1Left == null)
            {
                AddBoardThree(board.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level1Right = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == board.ClientUserId && p.Position == Position.Right);
            if (level1Right == null)
            {
                AddBoardThree(board.ClientUserId, attachThis, Position.Right);
                return false;
            }
            //4
            var level2Left1 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level1Left.ClientUserId && p.Position == Position.Left);
            if (level2Left1 == null)
            {
                AddBoardThree(level1Left.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level2Right1 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level1Left.ClientUserId && p.Position == Position.Right);
            if (level2Right1 == null)
            {
                AddBoardThree(level1Left.ClientUserId, attachThis, Position.Right);
                return false;
            }
            var level2Left2 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level1Right.ClientUserId && p.Position == Position.Left);
            if (level2Left2 == null)
            {
                AddBoardThree(level1Right.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level2Right2 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level1Right.ClientUserId && p.Position == Position.Right);
            if (level2Right2 == null)
            {
                AddBoardThree(level1Right.ClientUserId, attachThis, Position.Right);
                return false;
            }

            //8
            var level3Left1 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Left1.ClientUserId && p.Position == Position.Left);
            if (level3Left1 == null)
            {
                AddBoardThree(level2Left1.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level3Right1 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Left1.ClientUserId && p.Position == Position.Right);
            if (level3Right1 == null)
            {
                AddBoardThree(level2Left1.ClientUserId, attachThis, Position.Right);
                return false;
            }
            var level3Left2 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Right1.ClientUserId && p.Position == Position.Left);
            if (level3Left2 == null)
            {
                AddBoardThree(level2Right1.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level3Right2 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Right1.ClientUserId && p.Position == Position.Right);
            if (level3Right2 == null)
            {
                AddBoardThree(level2Right1.ClientUserId, attachThis, Position.Right);
                return false;
            }
            var level3Left3 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Left2.ClientUserId && p.Position == Position.Left);
            if (level3Left3 == null)
            {
                AddBoardThree(level2Left2.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level3Right3 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Left2.ClientUserId && p.Position == Position.Right);
            if (level3Right3 == null)
            {
                AddBoardThree(level2Left2.ClientUserId, attachThis, Position.Right);
                return false;
            }
            var level3Left4 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Right2.ClientUserId && p.Position == Position.Left);
            if (level3Left4 == null)
            {
                AddBoardThree(level2Right2.ClientUserId, attachThis, Position.Left);
                return false;
            }
            var level3Right4 = Context.BoardThree.FirstOrDefault(p => p.UplineUserId == level2Right2.ClientUserId && p.Position == Position.Right);
            if (level3Right4 == null)
            {
                AddBoardThree(level2Right2.ClientUserId, attachThis, Position.Right);
            }

            return true;
        }