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)); }
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())); }
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 })); }
public async Task <ResponseModel> GetUserMyData() { return(await ResponseModel.SuccessRequestAsync(_wsUserInfo)); }