コード例 #1
0
        /// <summary>Joins the collective asynchronous.</summary>
        /// <param name="collectiveid">The collectiveid.</param>
        /// <returns></returns>
        internal async Task <bool> JoinCollectiveAsync(int collectiveid)
        {
            var currentUser    = System.Text.Json.JsonSerializer.Deserialize <User>(ReadSetting("CurrentUser"));
            var collectiveuser = new CollectiveUser()
            {
                CollectiveId = collectiveid, UserId = currentUser.Id
            };
            var collectiveuserJson = JsonConvert.SerializeObject(collectiveuser);

#pragma warning disable CA2000 // Dispose objects before losing scope
            var userStringContent = new StringContent(collectiveuserJson, Encoding.UTF8, "application/json");
#pragma warning restore CA2000 // Dispose objects before losing scope
            if (await CrudHandler.JoinCollective(userStringContent, ReadSetting("AuthInfo")).ConfigureAwait(true))
            {
                userStringContent.Dispose();
                return(true);
            }
            else
            {
                return(false);
            }
        }