public TariffsReallocator ReallocateSalesParts(int oldTariff, int newTariff) { var uri = new Uri($"{this.rootUri}/products/tariffs/reallocate", UriKind.RelativeOrAbsolute); var resource = new TariffReallocatorResource { NewTariffId = newTariff, OldTariffId = oldTariff }; var response = this.restClient.Post <TariffReallocatorResource>(CancellationToken.None, uri, resource); if (response.Result.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"status code {response.Result.StatusCode}"); } var returnedResource = response.Result.Value; var reallocatorToReturn = new TariffsReallocator { Count = returnedResource.Count, NewTariffId = returnedResource.NewTariffId, OldTariffId = returnedResource.OldTariffId }; return(reallocatorToReturn); }
public void SetUp() { this.requestResource = new TariffReallocatorResource { NewTariffId = 21, OldTariffId = 20 }; var tariffReallocatorResponseModel = new ResponseModel <TariffsReallocator>(new TariffsReallocator { NewTariffId = 21, OldTariffId = 20 }, new List <string>()); this.TariffService.Reallocate(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <List <string> >()) .Returns(new SuccessResult <ResponseModel <TariffsReallocator> >(tariffReallocatorResponseModel)); this.AuthorisationService.HasPermissionFor(AuthorisedAction.ReallocateSalesArticles, Arg.Any <List <string> >()) .Returns(true); this.Response = this.Browser.Post( "/products/maint/tariffs-reallocate", with => { with.Header("Accept", "application/json"); with.JsonBody(this.requestResource); }).Result; }