Пример #1
0
        public async Task AddStateTracking(ObjectStateDto dto)
        {
            var objectState = ObjectStateDto.Map(dto);
            await _dbContext.AddAsync(objectState);

            await _dbContext.SaveChangesAsync();
        }
Пример #2
0
        public async Task <List <ObjectStateDto> > GetTableData(int tableId)
        {
            var tableData = await _dbContext.ObjectStates.Where(os => os.Table.Id == tableId)
                            .ToListAsync();

            return(tableData.Select(objState => ObjectStateDto.Map(objState))
                   .ToList());
        }
Пример #3
0
        public async Task UpdateDataObject(ObjectStateDto objectDto)
        {
            var objectState = await _dbContext.ObjectStates.Where(os => os.ObjectId == objectDto.ObjectId).SingleAsync();

            objectState.StateId     = objectDto.StateId;
            objectState.Title       = objectDto.Title;
            objectState.Description = objectDto.Description;
            await _dbContext.SaveChangesAsync();
        }
Пример #4
0
 /// <summary>
 /// Takes an dto and updates the elements.
 /// </summary>
 public void Update(ObjectStateDto dto)
 {
     _ballX = dto.BallX;
     _ballY = -dto.BallY;
     _bat1X = dto.Bat1X;
     _bat1Y = -dto.Bat1Y;
     _bat2X = dto.Bat2X;
     _bat2Y = -dto.Bat2Y;
     NotifyPropertyChanged("");
 }
Пример #5
0
        public async Task AddStateTracking <TEntity>(int objectId)
            where TEntity : BaseEntity
        {
            var table = await GetTable <TEntity>();

            var entity = await _dbContext.Set <TEntity>().SingleAsync(entity => entity.Id == objectId);

            var statefullManager = new StatefullManager(entity);

            var objectStateDto = new ObjectStateDto
            {
                ObjectId    = objectId,
                TableId     = table.Id,
                Title       = statefullManager.GetTitle(),
                Description = statefullManager.GetDescription()
            };

            await AddStateTracking(objectStateDto);
        }
Пример #6
0
        public void MoveBallOver1Sec(ObjectStateDto dto)
        {
            //GameViewModel.Update(dto);
            var deltaX     = (dto.BallXIn1Sec - dto.BallX) / (float)_settings.UpdatesASecond;
            var deltaY     = -((dto.BallYIn1Sec - dto.BallY) / (float)_settings.UpdatesASecond);
            var deltaBat1X = (dto.Bat1XIn1Sec - dto.Bat1X) / (float)_settings.UpdatesASecond;
            var deltaBat1Y = -((dto.Bat1YIn1Sec - dto.Bat1Y) / (float)_settings.UpdatesASecond);
            var deltaBat2X = (dto.Bat2XIn1Sec - dto.Bat2X) / (float)_settings.UpdatesASecond;
            var deltaBat2Y = -((dto.Bat2YIn1Sec - dto.Bat2Y) / (float)_settings.UpdatesASecond);

            _objectStateTimer = new Timer(state =>
            {
                dto.BallX += deltaX;
                dto.BallY += deltaY;
                dto.Bat1X += deltaBat1X;
                dto.Bat1Y += deltaBat1Y;
                dto.Bat2X += deltaBat2X;
                dto.Bat2Y += deltaBat2Y;
                GameViewModel.Update(dto);
            }, null, DateTime.Now.Second, _settings.UpdatesASecond);
        }
Пример #7
0
        public async Task <IActionResult> Update([FromBody] ObjectStateDto dto)
        {
            await _tableService.UpdateDataObject(dto);

            return(Ok());
        }
Пример #8
0
        public void Tick(object state)
        {
            var dto = new ObjectStateDto();

            _client.Send(JsonConvert.SerializeObject(dto));
        }