Пример #1
0
        /// <summary>
        /// Creates a new favorite associated to a specific user.
        /// </summary>
        /// <param name="favorite">A Favorite object</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The updated Favorite</returns>
        public async Task <Helpers.Favorite> CreateFavoriteAsync(Helpers.Favorite favorite, CancellationToken cancellationToken = default(CancellationToken))
        {
            string jsonResponse = await JsonClient.CreateFavoriteAsync(favorite.UpdateFor <Helpers.Favorite.Creation>().ToJson(), cancellationToken);

            favorite.Update(jsonResponse);

            return(favorite);
        }
Пример #2
0
        /// <summary>
        /// Delete an existing favorite associated to a specific user.
        /// </summary>
        /// <param name="favorite">A Favorite object</param>
        /// <param name="cancellationToken"></param>
        /// <returns>Nothing</returns>
        public async Task <string> DeleteFavoriteAsync(Helpers.Favorite favorite, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (favorite.Id == null)
            {
                throw new Exceptions.SendSecureException("Favorite id cannot be null");
            }

            return(await JsonClient.DeleteFavoriteAsync(favorite.Id, cancellationToken));
        }
Пример #3
0
        /// <summary>
        /// Delete contact methods of an existing favorite associated to a specific user.
        /// </summary>
        /// <param name="favorite">A Favorite object</param>
        /// <param name="contactMethodsIds">A list of contact methods ids</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The updated Favorite</returns>
        public async Task <Helpers.Favorite> DeleteFavoriteContactMethods(Helpers.Favorite favorite, List <int?> contactMethodsIds, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (favorite.Id == null)
            {
                throw new Exceptions.SendSecureException("Favorite id cannot be null");
            }

            string jsonResponse = await JsonClient.EditFavoriteAsync(favorite.UpdateFor <Helpers.Favorite.Destruction>().OfFollowingContacts(contactMethodsIds).ToJson(), favorite.Id, cancellationToken);

            favorite.Update(jsonResponse);

            return(favorite);
        }
Пример #4
0
        /// <summary>
        /// Update an existing favorite associated to a specific user.
        /// </summary>
        /// <param name="favorite">A Favorite object</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The updated Favorite</returns>
        public async Task <Helpers.Favorite> EditFavoriteAsync(Helpers.Favorite favorite, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (favorite.Id == null)
            {
                throw new Exceptions.SendSecureException("Favorite id cannot be null");
            }

            string jsonResponse = await JsonClient.EditFavoriteAsync(favorite.UpdateFor <Helpers.Favorite.Edition>().ToJson(), favorite.Id, cancellationToken);

            favorite.Update(jsonResponse);

            return(favorite);
        }