Beispiel #1
0
        //Обновляем счётчик онлайн игроков
        private void SaveOnlineCounters()
        {
#if !DEBUG
            using (GamePortalEntities db = new GamePortalEntities())
            {
                //удаляем устаревшие данные
                DateTimeOffset             time     = DateTimeOffset.UtcNow - _CounterLiveTime;
                IQueryable <OnlineCounter> oldLikes = db.OnlineCounters.Where((p) => p.id != Guid.Empty && p.dateTime < time);
                db.OnlineCounters.RemoveRange(oldLikes);

                //Добавляем новое значение
                OnlineCounter newCounter = new OnlineCounter()
                {
                    id = Guid.NewGuid(), dateTime = DateTimeOffset.UtcNow, count = _OnlineUsers.Count
                };
                db.OnlineCounters.Add(newCounter);

                //изменяем максимум
                OnlineCounter maxCounter = db.OnlineCounters.Single((p) => p.id == Guid.Empty);
                if (newCounter.count >= maxCounter.count)
                {
                    maxCounter.count    = newCounter.count;
                    maxCounter.dateTime = newCounter.dateTime;
                }

                db.SaveChanges();
            }
#endif
        }
Beispiel #2
0
        public Dictionary <string, string> GetPrivateProfileData(string login)
        {
            if (string.IsNullOrEmpty(login))
            {
                return(null);
            }

            using (GamePortalEntities gamePortal = new GamePortalEntities())
            {
                User user = gamePortal.Users.FirstOrDefault(p => p.Login == login);
                if (user == null)
                {
                    return(null);
                }

                Dictionary <string, string> result = new Dictionary <string, string>
                {
                    { "clientId", user.LastApiUser.ClientId },
                    { "email", user.LastApiUser.email },
                    { "password", user.Password }
                };

                return(result);
            }
        }
Beispiel #3
0
        public WCFUser GetProfileByLogin(string login)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login))
                {
                    return(null);
                }

                using (GamePortalEntities gamePortal = new GamePortalEntities())
                {
                    User gpUser = gamePortal.Users.FirstOrDefault(p => p.Login == login);
                    if (gpUser == null)
                    {
                        return(null);
                    }

                    WCFUser result = gpUser.ToWCFUser(gamePortal);

#if DEBUG
                    /*var xml = new PublicFileJson<WCFUser>("GetProfileByLogin.txt");
                     * xml.Value = result;
                     * xml.Write();*/
#endif

                    return(result);
                }
            }
            catch
            {
                return(null);
            }
        }
Beispiel #4
0
        public void PayPalPayment(string operationId, string login, string comment, bool isPublic, int power)
        {
            using (GamePortalEntities gamePortal = new GamePortalEntities())
            {
                if (gamePortal.Payments.Any(p => p.Event == operationId))
                {
                    return;
                }

                User gpUser = gamePortal.Users.SingleOrDefault(p => p.Login == login);
                if (gpUser == null)
                {
                    comment  = string.Format("Неизвестный пользователь: {0}, comment = {1}, isPublic = {2}", login, comment, isPublic);
                    isPublic = false;
                    gpUser   = gamePortal.Users.Single(p => p.Login == "17a87d89-b8d7-4274-9049-78d7b6af94af");
                }

                gpUser.Payments.Add(new Payment()
                {
                    Event = operationId, Id = Guid.NewGuid(), Comment = string.IsNullOrWhiteSpace(comment) ? null : comment, IsPublic = isPublic, Power = power, Time = DateTimeOffset.UtcNow
                });
                gpUser.Version = Guid.NewGuid();
                gamePortal.SaveChanges();

                UserInviteFunc(gpUser.ToWCFUser(gamePortal), "17a87d89-b8d7-4274-9049-78d7b6af94af", string.Format("Заплатил: {0}. Коментарий: {1}", power, comment));

                if (gpUser.Login != "17a87d89-b8d7-4274-9049-78d7b6af94af")
                {
                    gpUser = gamePortal.Users.Single(p => p.Login == "17a87d89-b8d7-4274-9049-78d7b6af94af");
                    UserInviteFunc(gpUser.ToWCFUser(gamePortal), login, "dynamic_thanks");
                }
            }
        }
Beispiel #5
0
        public List <string> GetOnlineUsers(string login)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login))
                {
                    return(null);
                }

                using (GamePortalEntities gamePortal = new GamePortalEntities())
                {
                    User gpUser = gamePortal.Users.FirstOrDefault(p => p.Login == login);
                    if (gpUser == null || gpUser.AllPower < 100)
                    {
                        return(null);
                    }
                }

                List <string> result = _OnlineUsers.Keys.ToList();

#if DEBUG
                /*var xml = new PublicFileJson<List<string>>("GetOnlineUsers.txt");
                 * xml.Value = result;
                 * xml.Write();*/
#endif

                return(result);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #6
0
        public Message GetCurrentProfit()
        {
            //try
            //{
            WebOperationContext current = WebOperationContext.Current;

            //return await GamePortalServer.TaskFactory.StartNew<Message>(() =>
            //{
            try
            {
                using (GamePortalEntities db = new GamePortalEntities())
                {
                    int   total  = db.Payments.Sum(p => p.Power);
                    float result = total / ProjectPrice;
                    return(ExtHttp.GetJsonStream(result.ToString("P"), current));
                }
            }
            catch
            {
                return(null);
            }
            //    });
            //}
            //catch
            //{
            //    return null;
            //}
        }
Beispiel #7
0
        public List <string> GetLikeProfile(string login)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login))
                {
                    return(null);
                }

                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    User user = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (user == null || (user.AllPower < 100))
                    {
                        return(null);
                    }

                    List <string> clientIdList = user.ApiUsers.Select(p => p.ClientId).ToList();
                    return(dbContext.Users.Where(p => p.Login != user.Login &&
                                                 !string.IsNullOrEmpty(p.Password) &&
                                                 !p.UserGames.Any(p1 => !p1.EndTime.HasValue) &&
                                                 p.ApiUsers.Any(p1 => clientIdList.Any(p2 => p2 == p1.ClientId)))
                           .Select(p => p.Login).ToList());
                }
            }
            catch
            {
                return(null);
            }
        }
Beispiel #8
0
        public void PassRate(string login, Guid id)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login) || id == Guid.Empty)
                {
                    return;
                }

                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    User gpUser = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (gpUser == null)
                    {
                        return;
                    }

                    UserGame userGame = gpUser.UserGames.FirstOrDefault(p => p.Id == id);
                    if (userGame == null)
                    {
                        return;
                    }

                    userGame.IsIgnoreMind = false;
                    gpUser.Version        = Guid.NewGuid();
                    dbContext.SaveChanges();
                }
            }
            catch
            {
                return;
            }
        }
Beispiel #9
0
        public void YandexMoneyPayment(string[] split, int power, DateTimeOffset time, string operation_id)
        {
            using (GamePortalEntities gamePortal = new GamePortalEntities())
            {
                string login = split[0];

                User gpUser = gamePortal.Users.SingleOrDefault(p => p.Login == login);
                if (gpUser == null)
                {
                    split = new string[3] {
                        "17a87d89-b8d7-4274-9049-78d7b6af94af", "0", string.Format("Неизвестный пользователь: {0}", string.Join("|", split))
                    };
                    gpUser = gamePortal.Users.Single(p => p.Login == "17a87d89-b8d7-4274-9049-78d7b6af94af");
                }

                string comment = string.IsNullOrWhiteSpace(split[2]) ? null : split[2];
                gpUser.Payments.Add(new Payment()
                {
                    Event = operation_id, Id = Guid.NewGuid(), Power = power, Time = time, IsPublic = split[1] == "1", Comment = comment
                });
                gpUser.Version = Guid.NewGuid();
                gamePortal.SaveChanges();

                UserInviteFunc(gpUser.ToWCFUser(gamePortal), "17a87d89-b8d7-4274-9049-78d7b6af94af", string.Format("Заплатил: {0}. Коментарий: {1}", power, comment));

                if (gpUser.Login != "17a87d89-b8d7-4274-9049-78d7b6af94af")
                {
                    gpUser = gamePortal.Users.Single(p => p.Login == "17a87d89-b8d7-4274-9049-78d7b6af94af");
                    UserInviteFunc(gpUser.ToWCFUser(gamePortal), login, "dynamic_thanks");
                }
            }
        }
Beispiel #10
0
        public List <ProfileVersion> GetProfilesVersion()
        {
            try
            {
                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    DateTimeOffset        time   = DateTimeOffset.UtcNow - GamePortalServer.DataLiveTime;
                    List <ProfileVersion> result = dbContext.Users.Where(p => p.ApiUsers.Max(p1 => p1.LastConnection) > time)
                                                   .Select(p => new ProfileVersion()
                    {
                        Login = p.Login, Version = p.Version
                    })
                                                   .ToList();

#if DEBUG
                    /*var xml = new PublicFileJson<List<ProfileVersion>>("GetProfilesVersion.txt");
                     * xml.Value = result;
                     * xml.Write();*/
#endif

                    return(result);
                }
            }
            catch
            {
                return(null);
            }
        }
Beispiel #11
0
        public void StopUserGame(string login, Guid gameId, int mindPosition = 0, bool isIgnoreHonor = false)
        {
            TaskFactory.StartNew(() =>
            {
                try
                {
                    using (GamePortalEntities gamePortal = new GamePortalEntities())
                    {
                        User gpUser = gamePortal.Users.SingleOrDefault(p => p.Login == login);
                        if (gpUser == null)
                        {
                            return;
                        }

                        UserGame userGame = gpUser.UserGames.SingleOrDefault(p => p.GameId == gameId);

                        if (userGame != null)
                        {
                            //Завершил игру
                            if (mindPosition != 0)
                            {
                                userGame.IsIgnoreHonor = false;
                                userGame.HonorPosition = 5;
                                userGame.MindPosition  = mindPosition;

                                AddUserNotifiFunc?.Invoke(gpUser.ToWCFUser(gamePortal), string.Format("dynamic_gameEnd*{0}*{1}", userGame.HomeType, userGame.MindPosition));
                            }
                            else
                            {
                                //наказание ослабевает по мере увеличения их количества в партии
                                userGame.HonorPosition = 6 - gamePortal.UserGames.Count(p => p.GameId == gameId && !p.EndTime.HasValue);
                                userGame.IsIgnoreHonor = isIgnoreHonor;

                                if (AddUserNotifiFunc != null)
                                {
                                    WCFUserGame wcfUserGame = userGame.ToWCFUserGame();
                                    if (wcfUserGame.IsIgnoreHonor)
                                    {
                                        AddUserNotifiFunc(gpUser.ToWCFUser(gamePortal), $"dynamic_leftGame1*{"unknown home"}");//userGame.HomeType
                                    }
                                    else
                                    {
                                        AddUserNotifiFunc(gpUser.ToWCFUser(gamePortal), $"dynamic_leftGame2*{"unknown home"}*0");//userGame.HomeType
                                    }
                                }
                            }

                            userGame.EndTime = DateTimeOffset.UtcNow;
                            gpUser.Version   = Guid.NewGuid();

                            gamePortal.SaveChanges();
                        }
                    }
                }
                catch
                {
                }
            });
        }
Beispiel #12
0
        public void LikeRate(string login, string likeLogin, bool?isLike)
        {
            if (string.IsNullOrWhiteSpace(login) ||
                string.IsNullOrWhiteSpace(likeLogin) ||
                login == likeLogin)
            {
                return;
            }

            try
            {
                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    User user = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (user == null)
                    {
                        return;
                    }

                    User likeUser = dbContext.Users.FirstOrDefault(p => p.Login == likeLogin);
                    if (likeLogin == null)
                    {
                        return;
                    }

                    UserLike userLike = likeUser.UserLikes.FirstOrDefault(p => p.LikeLogin == user.Login);
                    if (userLike != null)
                    {
                        likeUser.UserLikes.Remove(userLike);
                    }

                    if (isLike.HasValue)
                    {
                        likeUser.UserLikes.Add(new UserLike()
                        {
                            LikeLogin = user.Login,
                            IsLike    = isLike.Value,
                            Date      = DateTimeOffset.UtcNow
                        });
                    }

                    //user.Version = Guid.NewGuid();
                    likeUser.Version = Guid.NewGuid();
                    dbContext.SaveChanges();
                }
            }
            catch
            {
                return;
            }
        }
Beispiel #13
0
        /// <summary>
        /// редактирует чёрнобелый список пользователя
        /// </summary>
        /// <param name="login"></param>
        /// <param name="specialLogin"></param>
        /// <param name="isBlock"></param>
        public bool SpecialUser(string login, string specialLogin, bool?isBlock)
        {
            try
            {
                //проверка наличия ключа доступа и входных данных
                if (string.IsNullOrWhiteSpace(login) ||
                    string.IsNullOrWhiteSpace(specialLogin) ||
                    (login == specialLogin && isBlock == true))
                {
                    return(false);
                }

                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    User user = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (user == null || (isBlock == false && user.AllPower < 200) || (isBlock == true && user.AllPower < 300))
                    {
                        return(false);
                    }

                    //удаление старой записи
                    SpecialUser value = user.SpecialUsers.FirstOrDefault(p => p.SpecialLogin == specialLogin);
                    if (value != null)
                    {
                        user.SpecialUsers.Remove(value);
                    }

                    //добавление новой
                    if (isBlock != null)
                    {
                        user.SpecialUsers.Add(new SpecialUser()
                        {
                            SpecialLogin = specialLogin, IsBlock = isBlock.Value
                        });
                    }

                    user.Version = Guid.NewGuid();
                    dbContext.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Beispiel #14
0
        public Message GetProfile(string uid, string gameId)
        {
            //try
            //{
            if (string.IsNullOrEmpty(uid) && string.IsNullOrEmpty(gameId))
            {
                return(null);
            }

            WebOperationContext current = WebOperationContext.Current;

            //return await GamePortalServer.TaskFactory.StartNew<Message>(() =>
            //{
            try
            {
                using (GamePortalEntities gamePortal = new GamePortalEntities())
                {
                    ApiUser user = uid == null?gamePortal.ApiUsers.FirstOrDefault(p => p.Login == gameId) : gamePortal.ApiUsers.FirstOrDefault(p => p.uid == uid);

                    if (user == null)
                    {
                        return(null);
                    }

                    Profile result = new Profile
                    {
                        Id       = user.Login,
                        FIO      = $"{user.first_name} {user.last_name}",
                        AllPower = user.User.AllPower
                    };
                    result.Titles.AddRange(user.User.Titles.Select(p => p.Name));

                    return(ExtHttp.GetJsonStream(result, current));
                }
            }
            catch
            {
                return(null);
            }
            //    });
            //}
            //catch
            //{
            //    return null;
            //}
        }
Beispiel #15
0
        public void StartUserGame(string login, string homeType, Guid gameId, int gameType, bool isIgnoreDurationHours = false, bool IsIgnoreMind = false)
        {
#if !DEBUG //не учитывать рейтинг в отладочном режиме
            StopUserGame(login, gameId);

            TaskFactory.StartNew(() =>
            {
                try
                {
                    using (GamePortalEntities gamePortal = new GamePortalEntities())
                    {
                        User gpUser = gamePortal.Users.SingleOrDefault(p => p.Login == login);
                        if (gpUser == null)
                        {
                            return;
                        }

                        UserGame userGame = gpUser.UserGames.SingleOrDefault(p => p.GameId == gameId);
                        if (userGame == null)
                        {
                            userGame = new UserGame()
                            {
                                Id                    = Guid.NewGuid(),
                                GameId                = gameId,
                                GameType              = gameType,//+1 - игра с рандомом
                                Login                 = login,
                                HomeType              = homeType,
                                StartTime             = DateTimeOffset.UtcNow,
                                User                  = gpUser,
                                IsIgnoreMind          = IsIgnoreMind,
                                IsIgnoreDurationHours = isIgnoreDurationHours
                            };
                            gpUser.UserGames.Add(userGame);
                            gpUser.Version = Guid.NewGuid();
                            gamePortal.SaveChanges();
                        }
                    }
                }
                catch
                {
                }
            });
#endif
        }
Beispiel #16
0
        public bool?InviteUser(string login, string inviteLogin, string msg)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login) ||
                    string.IsNullOrWhiteSpace(inviteLogin) ||
                    string.IsNullOrWhiteSpace(msg))
                {
                    return(false);
                }

                //система уведомлений не подключена
                if (UserInviteFunc == null)
                {
                    return(false);
                }

                //только онлайн пользователей
                //if (!_OnlineUsers.Any(p => p.Login == inviteLogin))
                //    return false;
                if (!_OnlineUsers.TryGetValue(inviteLogin, out WCFUser inviteUser))
                {
                    return(false);
                }

                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    User user = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (user == null || (user.AllPower < 200))
                    {
                        return(null);
                    }

                    bool result = UserInviteFunc(user.ToWCFUser(dbContext), inviteLogin, msg);

                    return(result);
                }
            }
            catch
            {
                return(false);
            }
        }
Beispiel #17
0
        public Message GetOnlineCounters()
        {
            //try
            //{
            WebOperationContext current = WebOperationContext.Current;

            //return await GamePortalServer.TaskFactory.StartNew<Message>(() =>
            //{
            try
            {
                using (GamePortalEntities db = new GamePortalEntities())
                {
                    List <OnlineCounter> items      = db.OnlineCounters.OrderBy(p => p.dateTime).ToList();
                    OnlineCounter        maxCounter = items.Single((p) => p.id == Guid.Empty);
                    items.Remove(maxCounter);

                    OnlineCounterModel result = new OnlineCounterModel
                    {
                        Items = items.Select(p => new OnlineCounterItemModel()
                        {
                            DateTime = p.dateTime, Count = p.count
                        }).ToList(),
                        MaxItem = new OnlineCounterItemModel()
                        {
                            DateTime = maxCounter.dateTime, Count = maxCounter.count
                        }
                    };
                    return(ExtHttp.GetJsonStream(result, current));
                }
            }
            catch
            {
                return(null);
            }
            //    });
            //}
            //catch
            //{
            //    return null;
            //}
        }
Beispiel #18
0
        }                                                                                                 //todo или OrderBy

        public WCFUser ToWCFUser(GamePortalEntities dbContext)
        {
            WCFUser result = new WCFUser
            {
                Login    = this.Login,
                IsIgnore = this.IsIgnore,
                Power    = this.Power,
                AllPower = this.AllPower,
                Version  = this.Version
            };

            var api = LastApiUser;

            result.LastConnection = api.LastConnection;
            //result.ClientId = api.ClientId;
            result.Api.Add("uid", api.uid);
            result.Api.Add("isFacebook", api.isFacebook.ToString());
            result.Api.Add("photo", api.photo);
            result.Api.Add("FIO", string.Format("{0} {1}", api.first_name, api.last_name));

            var time = DateTimeOffset.UtcNow - GamePortalServer.DataLiveTime;

            result.UserGames.AddRange(this.UserGames.Where(p => p.StartTime > time).Select(p => p.ToWCFUserGame()));
            result.UserLikes.AddRange(this.UserLikes.Where(p => p.Date > time).Select(p => p.ToWCFUserLike()));
            result.SpecialUsers.AddRange(this.SpecialUsers.Select(p => p.ToWCFSpecialUser()));
            result.SignerUsers = dbContext.SpecialUsers.Where(p => p.SpecialLogin == this.Login && !p.IsBlock).Select(p => p.Login).ToList();
            result.Title.AddRange(this.Titles.Select(p => p.Name));

            if (this.LastPayment != null && this.LastPayment.IsPublic)
            {
                result.LastPayment = new WCFPayment()
                {
                    Power   = this.LastPayment.Power,
                    Time    = this.LastPayment.Time,
                    Comment = this.LastPayment.Comment?.Substring(0, this.LastPayment.Comment.Length > 200 ? 200 : this.LastPayment.Comment.Length)
                };
            }

            return(result);
        }
Beispiel #19
0
        public bool ClearProfile(string login)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login))
                {
                    return(false);
                }

                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    //проверка ключа доступа
                    User user = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (user == null || (user.AllPower < 100))
                    {
                        return(false);
                    }

                    DateTimeOffset time = DateTimeOffset.UtcNow - GamePortalServer.DataLiveTime;
                    user.UserGames.Where(p => p.EndTime.HasValue).ToList().ForEach(p =>
                    {
                        p.StartTime = time;
                    });

                    dbContext.UserLikes.RemoveRange(user.UserLikes);

                    user.Version = Guid.NewGuid();
                    dbContext.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Beispiel #20
0
        public bool LinkAccounts(string login, string linkLogin, string password)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(login) ||
                    string.IsNullOrWhiteSpace(linkLogin) ||
                    string.IsNullOrWhiteSpace(password) ||
                    login == linkLogin)
                {
                    return(false);
                }

                using (GamePortalEntities dbContext = new GamePortalEntities())
                {
                    User user = dbContext.Users.FirstOrDefault(p => p.Login == login);
                    if (user == null || (user.AllPower < 100))
                    {
                        return(false);
                    }

                    List <string> clientIdList = user.ApiUsers.Select(p => p.ClientId).ToList();
                    User          linkUser     = dbContext.Users.FirstOrDefault(p => p.Login == linkLogin);
                    if (linkUser == null || string.IsNullOrEmpty(linkUser.Password) || linkUser.Password != password ||
                        linkUser.UserGames.Any(p1 => !p1.EndTime.HasValue) ||
                        !linkUser.ApiUsers.Any(p1 => clientIdList.Any(p2 => p2 == p1.ClientId)))
                    {
                        return(false);
                    }

                    linkUser.ApiUsers.ToList().ForEach(p => user.ApiUsers.Add(new ApiUser()
                    {
                        first_name     = p.first_name,
                        last_name      = p.last_name,
                        email          = p.email,
                        photo          = p.photo,
                        uid            = p.uid,
                        isFacebook     = p.isFacebook,
                        ClientId       = p.ClientId,
                        LastConnection = p.LastConnection,
                        emailConfirm   = p.emailConfirm
                    }));

                    linkUser.Titles.ToList().ForEach(p => user.Titles.Add(new Title()
                    {
                        Id   = p.Id,
                        Name = p.Name
                    }));

                    linkUser.Payments.ToList().ForEach(p => user.Payments.Add(new Payment()
                    {
                        Id       = p.Id,
                        Time     = p.Time,
                        Event    = p.Event,
                        Power    = p.Power,
                        Comment  = p.Comment,
                        IsPublic = p.IsPublic
                    }));

                    linkUser.UserGames.ToList().ForEach(p =>
                    {
                        if (user.UserGames.All(p1 => p1.GameId != p.GameId))
                        {
                            user.UserGames.Add(
                                new UserGame()
                            {
                                Id            = p.Id,
                                GameId        = p.GameId,
                                GameType      = p.GameType,
                                StartTime     = p.StartTime,
                                EndTime       = p.EndTime,
                                HomeType      = p.HomeType,
                                HonorPosition = p.HonorPosition,
                                MindPosition  = p.MindPosition,
                                IsIgnoreHonor = p.IsIgnoreHonor,
                                IsIgnoreMind  = p.IsIgnoreMind
                            });
                        }
                    });

                    //кто лайкнул меня
                    linkUser.UserLikes.ToList().ForEach(p =>
                    {
                        if (!user.UserLikes.Any(p1 => p.LikeLogin == p1.LikeLogin))
                        {
                            user.UserLikes.Add(new UserLike()
                            {
                                LikeLogin = p.LikeLogin,
                                Date      = p.Date,
                                IsLike    = p.IsLike
                            });
                        }
                    });

                    //Кому я поставил лайки
                    dbContext.UserLikes.Where(p => p.LikeLogin == linkUser.Login).ToList().ForEach(p =>
                    {
                        if (!p.User.UserLikes.Any(p1 => p1.LikeLogin == user.Login))
                        {
                            dbContext.UserLikes.Add(new UserLike()
                            {
                                Login     = p.Login,
                                LikeLogin = user.Login,
                                IsLike    = p.IsLike,
                                Date      = p.Date
                            });
                        }

                        p.User.Version = Guid.NewGuid();
                        dbContext.UserLikes.Remove(p);
                    });

                    //кто у меня в списке
                    linkUser.SpecialUsers.ToList().ForEach(p =>
                    {
                        if (!user.SpecialUsers.Any(p1 => p.SpecialLogin == p1.SpecialLogin))
                        {
                            user.SpecialUsers.Add(new SpecialUser()
                            {
                                SpecialLogin = p.SpecialLogin,
                                IsBlock      = p.IsBlock
                            });
                        }
                    });

                    //Кто меня добавил в исключения
                    dbContext.SpecialUsers.Where(p => p.SpecialLogin == linkUser.Login).ToList().ForEach(p =>
                    {
                        if (!p.User.SpecialUsers.Any(p1 => p1.SpecialLogin == user.Login))
                        {
                            dbContext.SpecialUsers.Add(new SpecialUser()
                            {
                                Login        = p.Login,
                                SpecialLogin = user.Login,
                                IsBlock      = p.IsBlock
                            });
                        }

                        p.User.Version = Guid.NewGuid();
                        dbContext.SpecialUsers.Remove(p);
                    });

                    user.Version = Guid.NewGuid();
                    dbContext.Users.Remove(linkUser);
                    dbContext.SaveChanges();

                    //Заменяем участи в играх
                    ChangeGameWhenLinkAccounts?.Invoke(login, linkLogin);

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }