/// <summary> /// Creates the registrys. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> CreateRegistrys(CreateRegistryRequest request) { try { var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PostAsync(servicesConfig.ECommerce + ECommerceServiceOperation.CreateRegistry(), contentPost); if (response.IsSuccessStatusCode) { var multicode = JsonConvert.DeserializeObject <RegistryResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(multicode, HttpStatusCode.Created)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'CreateMultiCode()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Gets the registrys. /// </summary> /// <param name="orderParameters">The order parameters.</param> /// <returns></returns> public async Task <APIResponse> GetRegistrys(RegistryParameters orderParameters) { try { var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); UriBuilder url = new UriBuilder(servicesConfig.ECommerce + ECommerceServiceOperation.GetRegistry()); url.Query = QueryStringHelper.ConvertToQueryString(orderParameters); var response = await client.GetAsync(url.ToString()); if (response.IsSuccessStatusCode) { var multicode = JsonConvert.DeserializeObject <List <RegistryResponse> >(await response.Content.ReadAsStringAsync()); return(new APIResponse(multicode, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetMultiDetails()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
public async Task <APIResponse> GetProducts(ProductParameters cartParameters) { try { var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); UriBuilder url = new UriBuilder(servicesConfig.ECommerce + ECommerceServiceOperation.GetProducts()); url.Query = QueryStringHelper.ConvertToQueryString(cartParameters); var response = await client.GetAsync(url.ToString()); if (response.IsSuccessStatusCode) { var products = JsonConvert.DeserializeObject <List <ProductResponse> >(await response.Content.ReadAsStringAsync()); foreach (var item1 in products) { byte[] b = System.IO.File.ReadAllBytes(item1.Image); item1.Image = Convert.ToBase64String(b); } return(new APIResponse(products, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetMultiDetails()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Deletes the registrys. /// </summary> /// <param name="registryId">The registry identifier.</param> /// <returns></returns> public async Task <APIResponse> DeleteRegistrys(int registryId) { try { var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); var response = await client.DeleteAsync(servicesConfig.ECommerce + ECommerceServiceOperation.DeleteRegistry(registryId)); return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'DeleteBranch()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Updates the registrys. /// </summary> /// <param name="registryId">The registry identifier.</param> /// <param name="request">The request.</param> /// <returns></returns> public async Task <APIResponse> UpdateRegistrys(int registryId, UpdateRegistryRequest request) { try { var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PutAsync(servicesConfig.ECommerce + ECommerceServiceOperation.UpdateRegistry(registryId), contentPost); return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'UpdateBranch()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
public async Task <APIResponse> CreateProducts(CreateProductsRequest request) { try { string filename = ""; var folderName = Path.Combine("Products"); var pathToSave = Path.Combine("D:", "HappyWedding", folderName); if (request.ProductImage.Length > 0) { string format = System.IO.Path.GetExtension(request.ProductImage.FileName); filename = request.CategoryId + "_Products_" + DateTime.Now + format; string filenme = filename.Replace(":", "."); var filePath = Path.Combine(pathToSave, filenme); using var fileStream = new FileStream(filePath, FileMode.Create); request.ProductImage.CopyTo(fileStream); request.Image = filePath; request.Image = null; } var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); var param = JsonConvert.SerializeObject(request); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = await client.PostAsync(servicesConfig.ECommerce + ECommerceServiceOperation.CreateProduct(), contentPost); if (response.IsSuccessStatusCode) { var multicode = JsonConvert.DeserializeObject <ProductResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(multicode, HttpStatusCode.Created)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'CreateMultiCode()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
/// <summary> /// Gets the registry by identifier. /// </summary> /// <param name="orderId">The order identifier.</param> /// <returns></returns> public async Task <APIResponse> GetRegistryById(int registryId) { try { var client = httpClientFactory.CreateClient(ECommerceServiceOperation.serviceName); var response = await client.GetAsync(servicesConfig.ECommerce + ECommerceServiceOperation.GetRegistryById(registryId)); if (response.IsSuccessStatusCode) { var multicode = JsonConvert.DeserializeObject <RegistryResponse>(await response.Content.ReadAsStringAsync()); return(new APIResponse(multicode, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetMultiCodeById()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }