/// <summary> /// Adds the service. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> AddService(AddServicesRequests request) { try { string filename = ""; var folderName = Path.Combine("Service"); var pathToSave = Path.Combine("D:", "HappyWedding", folderName); foreach (var item in request.AddServicesRequestList) { if (item.Photo.Length > 0) { string format = System.IO.Path.GetExtension(item.Photo.FileName); filename = item.VendorId + "_Service_" + DateTime.Now + format; string filenme = filename.Replace(":", "."); var filePath = Path.Combine(pathToSave, filenme); using var fileStream = new FileStream(filePath, FileMode.Create); item.Photo.CopyTo(fileStream); item.PhotoPath = filePath; item.PhotoPath = null; } } var client = httpClientFactory.CreateClient(VendorServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PostAsync(servicesConfig.Vendor + VendorServiceOperation.AddService(), contentPost); return(JsonConvert.DeserializeObject <APIResponse>(await response.Content.ReadAsStringAsync())); } catch (Exception ex) { logger.Error(ex, "Exception in method 'AddService()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }