Esempio n. 1
0
        public override async Task OnConnectedAsync()
        {
            //  var currentUserId = Context.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            using (var context = new ChefContext())
            {
                var connection =
                    context.Connection.FirstOrDefault(i =>
                                                      i.UserId == Guid.Parse("4bcbbcbf-d75f-4c0f-821c-2a833f800ff4"));
                if (connection != null)
                {
                    connection.ConnectionId = Context.ConnectionId;
                    connection.Connected    = true;
                }
                else
                {
                    context.Connection.Add(new Connection
                    {
                        Id           = Guid.NewGuid(),
                        UserId       = Guid.Parse("4bcbbcbf-d75f-4c0f-821c-2a833f800ff4"),
                        ConnectionId = Context.ConnectionId
                    });
                }

                context.SaveChanges();


                await Clients.Caller.SendAsync("GetConnectionId", this.Context.ConnectionId);


                await base.OnConnectedAsync();
            }
        }
Esempio n. 2
0
        public override Task OnDisconnectedAsync(Exception exception)
        {
            using (var context = new ChefContext())
            {
                var connection = context.Connection.FirstOrDefault(i => i.ConnectionId == Context.ConnectionId);

                connection.Connected = false;
                context.SaveChanges();
            }

            return(base.OnDisconnectedAsync(exception));
        }
Esempio n. 3
0
 //  [AllowAnonymous]
 public Task SendNotification(Guid whoId, Guid sendId, string message)
 {
     using (var context = new ChefContext())
     {
         var who = context.Connection.FirstOrDefault(i => i.UserId == whoId && i.Connected == true);
         if (who != null)
         {
             return(Clients.User(who.ConnectionId).SendAsync("NotificationGuncelle"));
         }
         else
         {
             return(Clients.All.SendAsync("NotificationGuncelle"));
         }
     }
 }
 public DishController(ChefContext dContext)
 {
     dbDishContext = dContext;
 }
Esempio n. 5
0
 public ChefController(ChefContext context)
 {
     dbContext = context;
 }
Esempio n. 6
0
 public ChefController(ChefContext chContext)
 {
     dbChefContext = chContext;
 }
 public HomeController(ChefContext context)
 {
     db = context;
 }
Esempio n. 8
0
 public HomeController(ChefContext context)
 {
     _dbContext = context;
 }