public async Task AddUserFavorites() { var user = fillTestDbHelper.Users.FirstOrDefault(); var chat = fillTestDbHelper.Chats.FirstOrDefault(opt => opt.ChatUsers.Any(p => p.UserId == user.Id)); var channel = fillTestDbHelper.Channels.FirstOrDefault(opt => opt.ChannelUsers.Any(p => p.UserId == user.Id)); var channelFavorite = await favoritesService.AddUserFavoritesAsync(channel.ChannelId, null, null, user.Id); var chatFavorite = await favoritesService.AddUserFavoritesAsync(null, chat.Id, null, user.Id); var contactFavorite = await favoritesService.AddUserFavoritesAsync(null, null, user.Contacts.FirstOrDefault().ContactId, user.Id); Assert.True(channelFavorite.ChannelId == channel.ChannelId && chatFavorite.ChatId == chat.Id && contactFavorite.ContactId == user.Contacts.FirstOrDefault().ContactId); }
public async Task <Response> CreateResponseAsync() { UserFavoritesDto favorites = await favoritesService.AddUserFavoritesAsync( request.ChannelId, request.ChatId, request.ContactId, clientConnection.UserId.Value).ConfigureAwait(false); return(new FavoritesResponse(request.RequestId, new List <UserFavoritesVm> { UserFavoritesConverter.GetUserFavoriteVm(favorites, clientConnection.UserId.GetValueOrDefault()) })); }