public IResult <ResponseModel <TariffsReallocator> > Reallocate(int oldTariffId, int newTariffId, IEnumerable <string> privileges) { var reallocated = new TariffsReallocator(); try { reallocated = this.salesPartRepository.ReallocateSalesParts(oldTariffId, newTariffId); } catch (Exception ex) { return(new BadRequestResult <ResponseModel <TariffsReallocator> >($"Error occured whilst trying to update products from tariff {oldTariffId} to {newTariffId}: {ex.Message}")); } this.transactionManager.Commit(); return(new SuccessResult <ResponseModel <TariffsReallocator> >(new ResponseModel <TariffsReallocator>( reallocated, privileges))); }
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); }