示例#1
0
        public async Task <ActionResult> Get(int id)
        {
            var circleForReturn = _mapper.Map <CircleForReturnDto>(await _repo.GetCircle(id));
            var appUser         = await GetLoggedInUserAsync();

            if (appUser != null)
            {
                if (await _repo.IsOwner(appUser.Id, circleForReturn.Id))
                {
                    circleForReturn.IsManageable = true;
                    circleForReturn.IsMember     = true;
                }
                else if (await _repo.IsMember(appUser.Id, circleForReturn.Id))
                {
                    circleForReturn.IsMember = true;
                }
                else
                {
                    var request = await _repo.GetCircleRequest(appUser.Id, circleForReturn.Id);

                    if (request != null)
                    {
                        if (request.Declined)
                        {
                            circleForReturn.IsDeclined = true;
                        }
                        else
                        {
                            circleForReturn.IsWaitingApproval = true;
                        }
                    }
                }
            }

            circleForReturn.TotalMemberCount = await _repo.GetCircleMemberCount(id);

            return(Ok(circleForReturn));
        }
示例#2
0
        public void HandleRequest(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary)
        {
            var game   = gameRepository.GetGame(requestModel.GameIdentifier);
            var circle = circleRepository.GetCircle();
            var space  = circle.GetSpace(randomProvider.GetRandom(0, circle.CountSpaces()));

            game.HandleSpace(space);
            gameRepository.SaveGame(requestModel.GameIdentifier, game);
            var resultDescription = game.RequestLetter ? game.LetterDollarAmount.Value.ToString() : space.Type.ToString();

            outputBoundary.HandleResponse(new ResponseModel()
            {
                ResultDescription = resultDescription,
                RequestLetter     = game.RequestLetter,
                CurrentPlayerName = game.CurrentPlayer.Name
            });
        }