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(); } }
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)); }
// [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; }
public ChefController(ChefContext context) { dbContext = context; }
public ChefController(ChefContext chContext) { dbChefContext = chContext; }
public HomeController(ChefContext context) { db = context; }
public HomeController(ChefContext context) { _dbContext = context; }