Exemple #1
0
        public void SetUp()
        {
            DetachAllEntities();

            _equipmentsRepository = ServiceProvider.GetService <IEquipmentsRepository>();
            _dbContext            = ServiceProvider.GetService <ApplicationDbContext>();
        }
        /// <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();
        }
Exemple #3
0
 public EquipmentsController(IEquipmentsRepository equipmentsRepository, IUnitWork unitWork, IMapper mapper)
 {
     _equipmentsRepository = equipmentsRepository;
     _unitWork             = unitWork;
     _mapper = mapper;
 }
Exemple #4
0
 public EquipmentsController(IEquipmentsRepository equipmentsRepository, IMemoryCache memoryCache)
 {
     _equipmentsRepository = equipmentsRepository;
     _memoryCache          = memoryCache;
 }