Beispiel #1
0
        public async Task <ResponseModel> MessageToAll([SwaggerParameter(Required = true)] string message)
        {
            var allConnecttedUserIds = _socketHub.WSManager.UsersInfo().Where(user => user.Id != _wsUserInfo.Id).Select(v => v.Id);
            await _socketHub.SendNotificationAsync(allConnecttedUserIds, $"{_wsUserInfo.Name} user send '{message}' message", "Chat.MessageToAll");

            return(await ResponseModel.SuccessRequestAsync($"'{message}' message sended to all active users"));
        }
        public async Task <ResponseModel> Authorization([FromForm, SwaggerParameter("Name of user", Required = true)] string userName, [FromForm, SwaggerParameter("Id of user", Required = true)] int userId)
        {
            if (string.IsNullOrEmpty(userName) || userId == 0)
            {
                return(await ResponseModel.NoAccessAsync());
            }

            var token = await GenerateToken(userName, userId);

            return(await ResponseModel.SuccessRequestAsync(token));
        }
Beispiel #3
0
        public async Task <ResponseModel> Get()
        {
            var rng = new Random();

            return(await ResponseModel.SuccessRequestAsync(Products.Select(item => new Product
            {
                Name = item,
                Price = rng.Next(50, 500)
            })
                                                           .ToArray()));
        }
Beispiel #4
0
        public async Task <ResponseModel> DirectWithFriend([SwaggerParameter("This is must be another user's Id", Required = true)] Guid userId, [SwaggerParameter(Required = true)] string message)
        {
            await _socketHub.SendNotificationAsync(userId, $"{_wsUserInfo.Name} user send '{message}' message", "Chat.Message");

            return(await ResponseModel.SuccessRequestAsync($"'{message}' message sended to '{userId}' user"));
        }
 public async Task <ResponseModel> UserInfo()
 {
     return(await ResponseModel.SuccessRequestAsync(new { User.Identity?.IsAuthenticated, UserName = User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.Name)?.Value, UserId = User.Claims.SingleOrDefault(c => c.Type == "UserId")?.Value }));
 }
Beispiel #6
0
 public async Task <ResponseModel> GetUserMyData()
 {
     return(await ResponseModel.SuccessRequestAsync(_wsUserInfo));
 }