Пример #1
0
        public ActionResult <IResponse <object> > New(CreateGameInstanceDto dto)
        {
            var validationResponse = GameInstanceValidator.Validate(dto);

            if (!validationResponse.IsValid)
            {
                return(BadRequest(validationResponse));
            }

            var gameInstanceResponse = GameInstanceLogic.New(dto);

            var response = ResponseMapper.MapMetadata <GameInstanceDto>(gameInstanceResponse);

            response.Data = GameInstanceMapper.Map(gameInstanceResponse.Data);
            return(Ok(response));
        }
Пример #2
0
        public async Task <ActionResult <IResponse <object> > > PlayAsync(PlayGameInstanceDto dto)
        {
            var validationResponse = GameInstanceValidator.Validate(dto);

            if (!validationResponse.IsValid)
            {
                return(BadRequest(validationResponse));
            }

            var gameInstanceResponse = GameInstanceLogic.Play(dto);

            var response = ResponseMapper.MapMetadata <GameInstanceDto>(gameInstanceResponse);

            response.Data = GameInstanceMapper.Map(GameInstanceLogic.Get(dto.Id));
            if (response.IsValid)
            {
                await GameHubContext.Clients.Group(dto.Id.ToString()).SendAsync("Refresh");
            }
            return(Ok(response));
        }