public static async Task AddMovieAsync(Movie movie) { using (MultipartFormDataContent content = new MultipartFormDataContent("---------------" + (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds)) { content.Add(new StringContent(movie.Title), "Title"); content.Add(new StringContent(movie.Description), "Description"); content.Add(new StringContent(movie.Director), "Director"); content.Add(new StringContent(movie.Year.ToString()), "Year"); content.Add(new StringContent(movie.Price.ToString()), "Price"); content.Add(new StreamContent(new MemoryStream(ImageUtility.BitmapImageToByteArray(movie.Poster.Image, movie.Poster.Format))), "Poster", movie.Poster.FileName); using (HttpResponseMessage response = await MovieController.AddMovie(content)) { int status = (int)response.StatusCode; string body = await response.Content.ReadAsStringAsync(); if (status == 200) { return; } else if (status == 400) { throw new Exception(body); } else if (status == 401) { throw new UnauthenticatedException(); } else if (status == 403) { throw new UnauthorizedException(); } else if (status == 500) { throw new ServerException(); } else { throw new Exception("An uncaught error occurred."); } } } }