private void AddBoardTwo(int? uplineId, BoardOne user, Position? position) { Context.BoardTwo.Add(new BoardTwo() { ClientUserId = user.ClientUserId, DateCreated = DateTime.UtcNow.AddHours(8), Finished = false, Position = position, UplineUserId = uplineId }); }
private bool VerifyToBoard(BoardTwo board, BoardOne attachThis) { //2 var level1Left = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == board.ClientUserId && p.Position == Position.Left); if (level1Left == null) { AddBoardTwo(board.ClientUserId, attachThis, Position.Left); return false; } var level1Right = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == board.ClientUserId && p.Position == Position.Right); if (level1Right == null) { AddBoardTwo(board.ClientUserId, attachThis, Position.Right); return false; } //4 var level2Left1 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level1Left.ClientUserId && p.Position == Position.Left); if (level2Left1 == null) { AddBoardTwo(level1Left.ClientUserId, attachThis, Position.Left); return false; } var level2Right1 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level1Left.ClientUserId && p.Position == Position.Right); if (level2Right1 == null) { AddBoardTwo(level1Left.ClientUserId, attachThis, Position.Right); return false; } var level2Left2 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level1Right.ClientUserId && p.Position == Position.Left); if (level2Left2 == null) { AddBoardTwo(level1Right.ClientUserId, attachThis, Position.Left); return false; } var level2Right2 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level1Right.ClientUserId && p.Position == Position.Right); if (level2Right2 == null) { AddBoardTwo(level1Right.ClientUserId, attachThis, Position.Right); return false; } //8 var level3Left1 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Left1.ClientUserId && p.Position == Position.Left); if (level3Left1 == null) { AddBoardTwo(level2Left1.ClientUserId, attachThis, Position.Left); return false; } var level3Right1 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Left1.ClientUserId && p.Position == Position.Right); if (level3Right1 == null) { AddBoardTwo(level2Left1.ClientUserId, attachThis, Position.Right); return false; } var level3Left2 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Right1.ClientUserId && p.Position == Position.Left); if (level3Left2 == null) { AddBoardTwo(level2Right1.ClientUserId, attachThis, Position.Left); return false; } var level3Right2 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Right1.ClientUserId && p.Position == Position.Right); if (level3Right2 == null) { AddBoardTwo(level2Right1.ClientUserId, attachThis, Position.Right); return false; } var level3Left3 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Left2.ClientUserId && p.Position == Position.Left); if (level3Left3 == null) { AddBoardTwo(level2Left2.ClientUserId, attachThis, Position.Left); return false; } var level3Right3 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Left2.ClientUserId && p.Position == Position.Right); if (level3Right3 == null) { AddBoardTwo(level2Left2.ClientUserId, attachThis, Position.Right); return false; } var level3Left4 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Right2.ClientUserId && p.Position == Position.Left); if (level3Left4 == null) { AddBoardTwo(level2Right2.ClientUserId, attachThis, Position.Left); return false; } var level3Right4 = Context.BoardTwo.FirstOrDefault(p => p.UplineUserId == level2Right2.ClientUserId && p.Position == Position.Right); if (level3Right4 == null) { AddBoardTwo(level2Right2.ClientUserId, attachThis, Position.Right); } return true; }