Ejemplo n.º 1
0
        public string RequestGame(string username)
        {
            var userid = User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value;

            int acceptUserId  = repository.GetIdByColumName("UserName", username);
            int requestUserId = userid != null? requestUserId = Convert.ToInt32(userid):0;

            if (acceptUserId <= 0 || requestUserId <= 0)
            {
                return("user not found");
            }


            if (repository.CountActivGames(acceptUserId, requestUserId) > 0)
            {
                return("game exsist");
            }


            int gameId = repository.Insert(new Games()
            {
                AcceptUser  = acceptUserId,
                RequestUser = requestUserId,
                Status      = GameStatus.Wait
            });

            return("success");
        }