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));
        }
        public async Task <AdvertResponse> CreateAsync(CreateAdvertModel model)
        {
            AdvertModel advertApiModel = _mapper.Map <AdvertModel>(model);
            string      jsonModel      = JsonConvert.SerializeObject(advertApiModel);

            try
            {
                HttpResponseMessage response = await _client.PostAsync(new Uri($"{_baseAddress}/create"),
                                                                       new StringContent(jsonModel, Encoding.UTF8, "application/json"));

                string responseJson = await response.Content.ReadAsStringAsync();

                CreateAdvertResponse createAdvertResponse = JsonConvert.DeserializeObject <CreateAdvertResponse>(responseJson);
                AdvertResponse       advertResponse       = _mapper.Map <AdvertResponse>(createAdvertResponse);
                return(advertResponse);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(null);
        }