private async Task AddAsync(IFriend friend, int ownerId)
        {
            var vkApiAdder = _addFriendAvatarFactory.CreateFromVkApi(friend.VkId, friend.Photo50);
            var dbAdder = _addFriendAvatarFactory.CreateFromDatabase(friend.VkId, ownerId, AvatarSize.Small);

            var result = await _friendsAvatarsRepository.AddAsync(vkApiAdder);

            if (!result.Success)
                await _friendsAvatarsRepository.AddAsync(dbAdder);
        }
Exemplo n.º 2
0
        public FriendItem(IFriend friend)
        {
            InitializeComponent();

            if (this.NotInDesignMode())
            {
                _friend = friend;
                _fullName = string.Format("{0} {1}", friend.FirstName, friend.LastName);
                FullName.Content = _fullName;
            }
        }
Exemplo n.º 3
0
        public FriendContract ToContract(IFriend model)
        {
            var contract = new FriendContract
            {
                Id = model.Id,
                Name = model.Name
            };

            if (model.Photo != null)
            {
                contract.Photo = _photoMapper.ToContract(model.Photo);
            }

            return contract;
        }
Exemplo n.º 4
0
        public void Add(IFriend friend)
        {
            if (FriendViews.All(x => x.FriendId != friend.VkId))
            {
                var newModel = _friendItemViewModelFactory.CreateFriendItemViewModel(friend, _displayOnlineStatuses);
                var friendAvatar = _friendsAvatarsRepository.Data.FirstOrDefault(x => x.FriendId == friend.VkId);

                if (friendAvatar != null)
                    newModel.SetAvatar(friendAvatar.Content);

                var views = FriendViews.Select(x => x.Text)
                    .Union(new List<string> { newModel.Text  })
                    .OrderBy(x => x)
                    .ToList();

                var newModelIndex = views.IndexOf(newModel.Text);

                if (newModelIndex < views.Count)
                    FriendViews.Insert(newModelIndex, newModel);
                else
                    FriendViews.Add(newModel);
            }
        }
 public FriendSelectedEventArgs(IFriend friend)
 {
     Friend = friend;
 }
 public FriendOnlineStatusChangedEventArgs(IFriend friend)
 {
     Friend = friend;
 }
Exemplo n.º 7
0
        private void onOutgoingFriendInvitationAccepted(string displayName, IFriend friend)
        {
            DNotification notification = createNotification(false, "Friends.FriendsService.acceptedinvitation", displayName);

            trayNotificationManager.ShowNotification(notification);
        }
Exemplo n.º 8
0
        public void Remove(IFriend friend)
        {
            var model = FriendViews.FirstOrDefault(x => x.FriendId == friend.VkId);

            if (model != null)
                FriendViews.Remove(model);
        }
Exemplo n.º 9
0
 public FriendEventArgs(IFriend friend)
 {
     Friend = friend;
 }
Exemplo n.º 10
0
 private void onIncomingFriendInvitationAccepted(string displayName, IFriend friend)
 {
     notificationBreadcrumbController.RemoveBreadcrumb(friendRequestBreadcrumb);
 }
Exemplo n.º 11
0
 public UntrustedEventArgs(IFriend exTrustedFriend)
 {
     ExTrustedFriend = exTrustedFriend;
 }
 public void OnUnfriended(IFriend exFriend)
 {
     removeFriendStatusAndSwid(exFriend);
     onFriendsListUpdated();
 }
Exemplo n.º 13
0
 public void AddFriend(IFriend value)
 {
     Declarations.Add((Friend)value);
 }
Exemplo n.º 14
0
 /// <inheritdoc />
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:Tibia.Network.Game.AddedFriendEventArgs" /> class.
 /// </summary>
 /// <param name="characterSpawn">The character spawn.</param>
 /// <param name="friend">The friend.</param>
 public AddedFriendEventArgs(CharacterSpawn characterSpawn, IFriend friend)
 {
     CharacterSpawn = characterSpawn;
     Friend         = friend;
 }
Exemplo n.º 15
0
        public bool Delete(IFriend friend)
        {
            string sqlDelete = $@"DELETE FROM Friend WHERE Id='{friend.Id}'";

            return(ExeNonQueryCommand(sqlDelete));
        }
Exemplo n.º 16
0
        public bool Update(IFriend friend)
        {
            string sqlUpdate = $@"UPDATE Friend SET Name='{friend.Name}', Email='{friend.Email}', IsDeveloper='{friend.IsDeveloper}', BirthDate='{friend.BirthDate.ToString("s")}' WHERE Id='{friend.Id}'";

            return(ExeNonQueryCommand(sqlUpdate));
        }
Exemplo n.º 17
0
        public bool Insert(IFriend friend)
        {
            string sqlInsert = $@"INSERT INTO Friend VALUES('{friend.Id}','{friend.Name}','{friend.Email}','{friend.IsDeveloper}','{friend.BirthDate.ToString("s")}')";

            return(ExeNonQueryCommand(sqlInsert));
        }
Exemplo n.º 18
0
 public FriendItemSelectedEvent(IFriend friend)
 {
     Friend = friend;
 }
 public UnfriendedEventArgs(IFriend exFriend)
 {
     ExFriend = exFriend;
 }
Exemplo n.º 20
0
        public FriendItemViewModel(IFriend friend
            , bool displayOnlineStatus
            , ILoadingIndicatorViewModel loadingIndicatorViewModel
            , ILanguageRepository languageRepository
            , ILogger logger
            , IEventAggregator eventAggregator) 
            : base(languageRepository, logger, eventAggregator)
        {
            if (friend == null)
                throw  new ArgumentNullException(nameof(friend));

            _friend = friend;
            _displayOnlineStatus = displayOnlineStatus;

            LoadingIndicatorModel = loadingIndicatorViewModel;
            LoadingIndicatorModel.ImageScale = 0.5;

            UpdateText();
        }
Exemplo n.º 21
0
 public AcceptFriendInvitationResult(bool success, IFriend friend)
 {
     Success = success;
     Friend  = friend;
 }