public Task <IInventoryServiceCompletedMessage> UpdateQuantityAsync(RealTimeInventory product, int quantity) { var request = new UpdateQuantityMessage(product.ProductId, quantity); if (DontUseActorSystem) { return(PerformOperation( request , product.UpdateQuantityAsync(TestInventoryStorage, request.ProductId, request.Update), TestInventoryStorage .ReadInventoryAsync(request.ProductId) .Result.Result)); } return(inventoryActor.Ask <IInventoryServiceCompletedMessage>(request, GENERAL_WAIT_TIME)); }
public InventoryServiceServer(IPerformanceService performanceService, IBackUpService backUpService, InventoryServerOptions options = null) { Options = options ?? new InventoryServerOptions(); if (Options.DontUseActorSystem) { DontUseActorSystem = Options.DontUseActorSystem; TestInventoryStorage = Options.StorageType != null ? (IInventoryStorage)Activator.CreateInstance(Options.StorageType) : new Storage.InMemoryLib.InMemory(); if (Options.InitialInventory != null) { TestInventoryStorage.WriteInventoryAsync(Options.InitialInventory); } } else { Sys = Options.ClientActorSystem; InventoryServiceApplication = new InventoryServiceApplication(); if (string.IsNullOrEmpty(Options.InventoryActorAddress)) { Options.InventoryActorAddress = ConfigurationManager.AppSettings["RemoteInventoryActorAddress"]; } InventoryServiceApplication.Start(performanceService, backUpService, Options.OnInventoryActorSystemReady, Options.StorageType, serverEndPoint: Options.ServerEndPoint, serverActorSystemName: Options.ServerActorSystemName, serverActorSystem: Options.ServerActorSystem, serverActorSystemConfig: Options.ServerActorSystemConfig); Sys = Sys ?? InventoryServiceApplication.InventoryServiceServerApp.ActorSystem; var selection = Sys.ActorSelection(Options.InventoryActorAddress); inventoryActor = TryResolveActorSelection(selection); var serverEndPoint = Options.ServerEndPoint;//ConfigurationManager.AppSettings["ServerEndPoint"]; if (!string.IsNullOrEmpty(serverEndPoint)) { OwinRef = WebApp.Start <Startup>(url: serverEndPoint); } if (Options.InitialInventory != null) { InitializeWithInventorydata(Options); } } }