Beispiel #1
0
 public void Post([FromBody] PeopleUser value)
 {
     try
     {
         string userId = Request.Headers["userId"];
         value.UserId = userId;
         _context.PeopleUsers.Add(value);
         _context.SaveChanges();
         _hubContext.Clients.All.SendAsync("AddUser", value.Id);
     }
     catch (Exception) { }
 }
Beispiel #2
0
        private async void StartHub()
        {
            try
            {
                await _hubConnection.StartAsync();

                _hubConnection.On <string>("AddUser", (value) =>
                {
                    if (Users.Any(v => v.UserId == value))
                    {
                        return;
                    }
                    PeopleUser val = GetUser(value);
                    Users.Add(val);
                    OnCollectionChanged(NotifyCollectionChangedAction.Add, val);
                });
            }
            catch (Exception)
            {
                // ignored
            }
        }
Beispiel #3
0
 protected void OnCollectionChanged(NotifyCollectionChangedAction action, PeopleUser item)
 {
     CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(action, item));
 }