private async Task ImportUser(ProfileReply allrpgUser)
        {
            var usersRepository = UnitOfWork.GetUsersRepository();
            var user            = await usersRepository.GetByAllRpgId(allrpgUser.sid);

            if (user != null)
            {
                _operationLog.Info($"USER.FOUND: Id = {user.Id}, Email = {user.Email}, Allrpg = {user.Allrpg.Sid}");
                Users.Add(allrpgUser.sid, user);
                return;
            }

            var email  = allrpgUser.em.ToLowerInvariant();
            var email2 = allrpgUser.em2.ToLowerInvariant();

            user = await usersRepository.GetByEmail(email) ?? await usersRepository.GetByEmail(email2);

            string action;

            if (user == null)
            {
                var username = new[] { email, email2 }.WhereNotNullOrWhiteSpace().First();
                user = new User
                {
                    Email    = username,
                    UserName = username
                };
                UnitOfWork.GetDbSet <User>().Add(user);
                action = "CREATE";
            }
            else
            {
                action = "UPDATE";
            }
            Users.Add(allrpgUser.sid, user);
            user.Allrpg     = user.Allrpg ?? new AllrpgUserDetails();
            user.Allrpg.Sid = allrpgUser.sid;
            AllrpgImportUtilities.ImportUserFromResult(user, allrpgUser);

            _operationLog.Info($"USER.{action} Id = {user.Id}, Email = {user.Email}, Allrpg = {user.Allrpg.Sid}");
        }
        public static void ImportUserFromResult(User user, ProfileReply result)
        {
            user.Auth = user.Auth ?? new UserAuthDetails()
            {
                RegisterDate = DateTime.UtcNow
            };
            user.Extra = user.Extra ?? new UserExtra()
            {
                BirthDate = null
            };

            user.Allrpg.Sid = result.sid;

            var splitFio = result.fio.Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            user.SurName    = GetFioComponent(user.SurName, splitFio, 0);
            user.BornName   = GetFioComponent(user.BornName, splitFio, 1);
            user.FatherName = GetFioComponent(user.FatherName, splitFio, 2);

            if (user.Extra.Gender == Gender.Unknown && result.gender <= 2)
            {
                user.Extra.GenderByte = result.gender;
            }
            if (user.Extra.PhoneNumber == null)
            {
                user.Extra.PhoneNumber = result.phone2;
            }
            if (user.Extra.Nicknames == null)
            {
                user.Extra.Nicknames = result.nick;
                if (string.IsNullOrWhiteSpace(user.PrefferedName) && !string.IsNullOrWhiteSpace(user.Extra.Nicknames))
                {
                    user.PrefferedName = user.Extra.Nicknames;
                }
            }

            if (user.Extra.Skype == null)
            {
                user.Extra.Skype = result.skype;
            }

            if (user.Extra.Vk == null)
            {
                user.Extra.Vk = result.vkontakte;
            }

            if (user.Extra.Livejournal == null)
            {
                user.Extra.Livejournal = result.livejournal;
            }

            if (user.Extra.GroupNames == null)
            {
                user.Extra.GroupNames = result.ingroup;
            }

            if (user.Extra.BirthDate == null)
            {
                user.Extra.BirthDate = result.birth;
            }

            user.Auth.RegisterDate = new[] { user.Auth.RegisterDate, result.CreateDate }.Min();
        }