<commit_before>﻿using System;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using JoinRpg.Data.Write.Interfaces;
using JoinRpg.DataModel;
using JoinRpg.Helpers;
using JoinRpg.Services.Interfaces;

namespace JoinRpg.Services.Impl
{
  [UsedImplicitly]
  public class UserServiceImpl : DbServiceImplBase, IUserService
  {
    public UserServiceImpl(IUnitOfWork unitOfWork) : base(unitOfWork)
    {
    }

    public async Task UpdateProfile(int currentUserId, int userId, string surName, string fatherName, string bornName, string prefferedName, Gender gender, string phoneNumber, string nicknames, string groupNames, string skype, string vk, string livejournal)
    {
      if (currentUserId != userId)
      {
        throw new Exception("Not authorized");
      }
      var user = await UserRepository.WithProfile(userId);

      user.SurName = surName;
      user.FatherName = fatherName;
      user.BornName = bornName;
      user.PrefferedName = prefferedName;

      user.Extra = user.Extra ?? new UserExtra();
      user.Extra.Gender = gender;
      user.Extra.PhoneNumber = phoneNumber;
      user.Extra.Nicknames = nicknames;
      user.Extra.GroupNames = groupNames;
      user.Extra.Skype = skype;
      var tokensToRemove = new[] {"http://", "vk.com/", "vkontakte.ru/", ".livejournal.com", ".lj.ru", "/", "https://"};
      user.Extra.Livejournal = livejournal.RemoveFromString(tokensToRemove);
      user.Extra.Vk = vk.RemoveFromString(tokensToRemove);

      await UnitOfWork.SaveChangesAsync();
    }
  }
}<commit_msg>Fix vk saving in profile<commit_after>﻿using System;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using JoinRpg.Data.Write.Interfaces;
using JoinRpg.DataModel;
using JoinRpg.Helpers;
using JoinRpg.Services.Interfaces;

namespace JoinRpg.Services.Impl
{
  [UsedImplicitly]
  public class UserServiceImpl : DbServiceImplBase, IUserService
  {
    public UserServiceImpl(IUnitOfWork unitOfWork) : base(unitOfWork)
    {
    }

    public async Task UpdateProfile(int currentUserId, int userId, string surName, string fatherName, string bornName, string prefferedName, Gender gender, string phoneNumber, string nicknames, string groupNames, string skype, string vk, string livejournal)
    {
      if (currentUserId != userId)
      {
        throw new Exception("Not authorized");
      }
      var user = await UserRepository.WithProfile(userId);

      user.SurName = surName;
      user.FatherName = fatherName;
      user.BornName = bornName;
      user.PrefferedName = prefferedName;

      user.Extra = user.Extra ?? new UserExtra();
      user.Extra.Gender = gender;
      user.Extra.PhoneNumber = phoneNumber;
      user.Extra.Nicknames = nicknames;
      user.Extra.GroupNames = groupNames;
      user.Extra.Skype = skype;
      var tokensToRemove = new[] {"http://", "https://", "vk.com/", "vkontakte.ru/", ".livejournal.com", ".lj.ru", "/", };
      user.Extra.Livejournal = livejournal.RemoveFromString(tokensToRemove);
      user.Extra.Vk = vk.RemoveFromString(tokensToRemove);

      await UnitOfWork.SaveChangesAsync();
    }
  }
}
{'fraction_non_alphanumeric': 0.10927046830200701, 'fraction_numerical': 0.0, 'mean_word_length': 3.631268436578171, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5987817', 'n_tokens_mistral': 958, 'n_tokens_neox': 945, 'n_words': 214}