/// <summary> /// Creates the event. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> CreateEvent(CreateEventRequest request) { { try { string filename = ""; var folderName = Path.Combine("Events"); var pathToSave = Path.Combine("D:", "HappyWedding", folderName); if (request.CoverPhotos.Length > 0) { string format = System.IO.Path.GetExtension(request.CoverPhotos.FileName); filename = request.VendorId + "_Event_" + DateTime.Now + format; string filenme = filename.Replace(":", "."); var filePath = Path.Combine(pathToSave, filenme); using var fileStream = new FileStream(filePath, FileMode.Create); request.CoverPhotos.CopyTo(fileStream); request.CoverPhoto = filePath; request.CoverPhoto = 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.CreateEvent(), contentPost); var userprofile = JsonConvert.DeserializeObject <APIResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(userprofile, HttpStatusCode.Created)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'CreateUser()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } } }