public async Task <bool> ConfirmAsync(ConfirmAdvertRequest model)
        {
            ConfirmAdvertModel  confirmApiModel = _mapper.Map <ConfirmAdvertModel>(model);
            string              jsonModel       = JsonConvert.SerializeObject(confirmApiModel);
            HttpResponseMessage response        = await _client.PutAsync(new Uri($"{_baseAddress}/confirm"),
                                                                         new StringContent(jsonModel, Encoding.UTF8, "application/json"));

            return(response.StatusCode == HttpStatusCode.OK);
        }
        public async Task <IActionResult> Create(CreateAdvertViewModel model, IFormFile imageFile)
        {
            if (ModelState.IsValid)
            {
                CreateAdvertModel createAdvertModel = _mapper.Map <CreateAdvertModel>(model);
                AdvertResponse    apiCallResponse   = await _advertApiClient.CreateAsync(createAdvertModel);

                string id = apiCallResponse.Id;
                if (imageFile != null)
                {
                    string fileName = !string.IsNullOrEmpty(imageFile.FileName) ? Path.GetFileName(imageFile.FileName) : id;
                    var    filePath = $"{id}/{fileName}";

                    try
                    {
                        using var readStream = imageFile.OpenReadStream();
                        var result = await _fileUploader.UploadFileAsync(filePath, readStream);

                        if (!result)
                        {
                            throw new Exception("Could not upload image to the file repository. Please see logs for more detail");
                        }

                        ConfirmAdvertRequest confirmModel = new ConfirmAdvertRequest
                        {
                            Id       = id,
                            FilePath = filePath,
                            Status   = AdvertStatus.Active
                        };
                        bool canConfirm = await _advertApiClient.ConfirmAsync(confirmModel);

                        if (!canConfirm)
                        {
                            throw new Exception($"Cannot confirm upload for advert {id}");
                        }
                        return(RedirectToAction("Index", "Home"));
                    }
                    catch (Exception ex)
                    {
                        ConfirmAdvertRequest confirmModel = new ConfirmAdvertRequest
                        {
                            Id       = id,
                            FilePath = filePath,
                            Status   = AdvertStatus.Pending
                        };
                        await _advertApiClient.ConfirmAsync(confirmModel);

                        Console.WriteLine(ex.Message);
                    }
                }
            }

            return(View(model));
        }