public async Task <ExpenditureROResult> GetExpenditureById(List <int> id, string token) { List <ExpenditureROViewModel> expenditureRO = new List <ExpenditureROViewModel>(); ExpenditureROResult expenditureROResult = new ExpenditureROResult(); foreach (var item in id) { var garmentUnitExpenditureNoteUri = PurchasingDataSettings.Endpoint + $"garment-unit-expenditure-notes/ro-asal/{item}"; var httpResponse = await _http.GetAsync(garmentUnitExpenditureNoteUri, token); if (httpResponse.IsSuccessStatusCode) { var a = await httpResponse.Content.ReadAsStringAsync(); Dictionary <string, object> keyValues = JsonConvert.DeserializeObject <Dictionary <string, object> >(a); var b = keyValues.GetValueOrDefault("data"); var expenditure = JsonConvert.DeserializeObject <ExpenditureROViewModel>(keyValues.GetValueOrDefault("data").ToString()); ExpenditureROViewModel expenditureROViewModel = new ExpenditureROViewModel { ROAsal = expenditure.ROAsal, DetailExpenditureId = expenditure.DetailExpenditureId, BuyerCode = expenditure.BuyerCode }; expenditureRO.Add(expenditureROViewModel); } else { //await GetExpenditureById(id, token); } } expenditureROResult.data = expenditureRO; return(expenditureROResult); }
public XlsPrepareCommandHandlerTest() { _mockGarmentPreparingRepository = CreateMock <IGarmentPreparingRepository>(); _mockGarmentPreparingItemRepository = CreateMock <IGarmentPreparingItemRepository>(); _MockStorage.SetupStorage(_mockGarmentPreparingRepository); _MockStorage.SetupStorage(_mockGarmentPreparingItemRepository); _mockGarmentCuttingInRepository = CreateMock <IGarmentCuttingInRepository>(); _mockGarmentCuttingInItemRepository = CreateMock <IGarmentCuttingInItemRepository>(); _mockGarmentCuttingInDetailRepository = CreateMock <IGarmentCuttingInDetailRepository>(); _MockStorage.SetupStorage(_mockGarmentCuttingInRepository); _MockStorage.SetupStorage(_mockGarmentCuttingInItemRepository); _MockStorage.SetupStorage(_mockGarmentCuttingInDetailRepository); _mockGarmentAvalProductRepository = CreateMock <IGarmentAvalProductRepository>(); _mockGarmentAvalProductItemRepository = CreateMock <IGarmentAvalProductItemRepository>(); _MockStorage.SetupStorage(_mockGarmentAvalProductRepository); _MockStorage.SetupStorage(_mockGarmentAvalProductItemRepository); _mockGarmentDeliveryReturnRepository = CreateMock <IGarmentDeliveryReturnRepository>(); _mockGarmentDeliveryReturnItemRepository = CreateMock <IGarmentDeliveryReturnItemRepository>(); _MockStorage.SetupStorage(_mockGarmentDeliveryReturnRepository); _MockStorage.SetupStorage(_mockGarmentDeliveryReturnItemRepository); serviceProviderMock = new Mock <IServiceProvider>(); _mockhttpService = CreateMock <IHttpClientService>(); ExpenditureROViewModel expenditureROViewModel = new ExpenditureROViewModel { DetailExpenditureId = 1, ROAsal = "ROAsal" }; _mockhttpService.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{\"data\": " + JsonConvert.SerializeObject(expenditureROViewModel) + "}") }); serviceProviderMock.Setup(x => x.GetService(typeof(IHttpClientService))).Returns(_mockhttpService.Object); }