Пример #1
0
        public IActionResult StartEvent(int id)
        {
            var evt =
                _eventRepository.GetEventById(id);

            if (evt != null)
            {
                _eventRepository.CloseEvent(id);
                _connectionManager.GetHubContext <PostsHub>().Clients.All.StartQuiz("Quiz has started");
                return(Ok(evt));
            }
            return(BadRequest(_apiErrorHandler.GenerateErrorDto(new ErrorList("Quiz with that id doesnt exist"))));
        }
Пример #2
0
        public IActionResult JoinTeam([FromBody] TeamJoinDto model)
        {
            var result = _teamRepository.GetTeamById(model.TeamId);

            if (result != null)
            {
                if (result.EventId == model.EventId && result.Password == model.Password) //TODO team max
                {
                    var userName = User.Identity.Name;
                    var user     = _userRepository.GetUserByEmail(userName);
                    _teamRepository.AddMememberToTeam(model.TeamId, user.Result);
                    return(Ok(new MessageDto("Succesfull")));
                }
            }
            return(BadRequest(_apiErrorHandler.GenerateErrorDto(new ErrorList("Invalid data"))));
        }
Пример #3
0
        public async Task <IActionResult> Login([FromBody] FbToken fbtoken)
        {
            var result = await _authHandler.VerifyFacebookAccessToken(fbtoken.Token);

            if (result != null)
            {
                var token = await _membershipService.LoginToken(result);

                return(Ok(Mapper.Map <TokenDto>(token)));
            }
            return(BadRequest(_apiErrorHandler.GenerateErrorDto(new ErrorList("Invalid data"))));
        }