Exemplo n.º 1
0
        /// <summary>
        /// Asynchronously updates the <see cref="FileEntry" /> into the system.
        /// </summary>
        /// <param name="id">The unique identifier.</param>
        /// <param name="fileName">The file name.</param>
        /// <param name="file">The file.</param>
        public virtual async Task <bool> UpdateAsync(object id, string fileName, Stream file)
        {
            using (IBaasicClient client = BaasicClientFactory.Create(Configuration))
            {
                UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{1}", ModuleRelativePath, id)));
                var        result     = await client.PutFileAsync <HttpStatusCode>(uriBuilder.ToString(), file, fileName);

                switch (result)
                {
                case HttpStatusCode.Created:
                case HttpStatusCode.NoContent:
                case HttpStatusCode.OK:
                    return(true);

                default:
                    return(false);
                }
            }
        }