コード例 #1
0
        public async Task <APIResponse> GetCategoryDetailsByVendorId(string vendorId)
        {
            try
            {
                var client   = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);
                var response = await client.GetAsync(servicesConfig.Vendor + VendorServiceOperation.GetCategoryDetailsByVendorId(vendorId));

                if (response.IsSuccessStatusCode)
                {
                    var categoryResponses = JsonConvert.DeserializeObject <List <CategoryResponse> >(await response.Content.ReadAsStringAsync());

                    foreach (var item in categoryResponses)
                    {
                        var    categoryPicture = item.ProfileImage;
                        byte[] b = System.IO.File.ReadAllBytes(item.ProfilePicture);
                        item.ProfilePicture = Convert.ToBase64String(b);

                        var profilepicture = item.ProfilePictures;
                        foreach (var item1 in profilepicture)
                        {
                            byte[] b1 = System.IO.File.ReadAllBytes(item1.ProfilePicturePath);
                            item1.ProfilePicturePath = Convert.ToBase64String(b1);
                        }
                    }
                    return(new APIResponse(categoryResponses, HttpStatusCode.OK));
                }
                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'GetCategoryDetailsByVendorId()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }