/// <summary> /// This is the main entry point for your service replica. /// This method executes when this replica of your service becomes primary and has write status. /// </summary> /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param> protected override async Task RunAsync(CancellationToken cancellationToken) { // TODO: Replace the following sample code with your own logic // or remove this RunAsync override if it's not needed in your service. //var myDictionary = await this.StateManager.GetOrAddAsync<IReliableDictionary<string, long>>("myDictionary"); // Initilize base class constructor _repo = new ServiceFabricEquipmentRepository(this.StateManager); var equipment1 = new Equipment { Id = Guid.NewGuid(), Name = "Water Sensor", Description = "Water Sensor", Price = 500, Availability = 100 }; var equipment2 = new Equipment { Id = Guid.NewGuid(), Name = "Router", Description = "Router", Price = 400, Availability = 50 }; // Adding data to service fabric reliable statemanager database await _repo.AddEquipment(equipment1); await _repo.AddEquipment(equipment2); // This is to validate replica concept provided by service fabric IEnumerable <Equipment> all = await _repo.GetAllEquipment(); }
public async Task AddEquipmentAsync(Equipment equipment) { await _repo.AddEquipment(equipment); }