Ejemplo n.º 1
0
        public void SendDirectMessage(message messageData)
        {
            string targetUserName = messageData.toUserId;
            var    item           = _context.users.FirstOrDefault(x => x.username == targetUserName);

            _context.messages.AddAsync(messageData);
            _context.SaveChanges();

            System.Console.WriteLine(targetUserName + Context.User.Identity.Name);
            Clients.Client(item.socketId).SendAsync("SendDM", messageData, targetUserName);
        }
Ejemplo n.º 2
0
        public IActionResult Register([FromBody] user item)
        {
            Console.WriteLine(item);
            item.socketId = null;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _context.users.Add(item);

            _context.SaveChanges();

            return(StatusCode((int)System.Net.HttpStatusCode.Created, item.username));
        }