public async Task Login() { var user = await _userManager.FindByNameAsync(Context.User.Identity.Name); var hubUser = new UserHub() { UserName = Context.User.Identity.Name, ConnectionId = Context.ConnectionId, Role = user.Role }; _connectionService.LoginHubUser(hubUser); var allUsers = _connectionService.GetAllHubUsers(); if (user.Role == "Patient") { await Clients.Client(Context.ConnectionId) .SendAsync("UpdateUserList", JsonSerializer.Serialize(allUsers.Where(u => u.Role == "Doctor").ToArray())); await Clients.Clients(allUsers.Where(u => u.Role != "Patient").Select(u => u.ConnectionId).ToArray()) .SendAsync("NewUserArrived", JsonSerializer.Serialize(hubUser)); } else { await Clients.Client(Context.ConnectionId) .SendAsync("UpdateUserList", JsonSerializer.Serialize(allUsers.Where(u => u.ConnectionId != Context.ConnectionId).ToArray())); if (user.Role == "Doctor") { await Clients.AllExcept(Context.ConnectionId).SendAsync("NewUserArrived", JsonSerializer.Serialize(hubUser)); } } }
public bool DeleteUserHub(UserHub entity) { if (entity == null) return false; _unitOfWork.UserHubRepository.Delete(entity); _unitOfWork.Save(); return true; }
private void StartGame(UserHub host, UserHub guest) { IInputProvider inputProvider = new InputProvider(); IEngine engine = new TwoPlyersEngine(inputProvider); IGameInitializationStrategy strategy = new TwoPlayersInitializationStrategy(); engine.Initialize(strategy, host.Username, guest.Username); IOutputProvider outputProvider = new WebOutputProvider(); Guid gameId = Guid.NewGuid(); var players = new List <UserHub>() { host, guest }; var game = new GameHub(players, engine); Games.Add(game); var board = outputProvider.GetBoardToRender(engine); var nextPlayerName = players.FirstOrDefault(p => p.ConnectionId == game.NextPlayerId).Username; Clients.Client(host.ConnectionId).startGame(board); Clients.Client(guest.ConnectionId).startGame(board); Clients.Client(host.ConnectionId).recieveMessage($"Next player: {nextPlayerName}", "Judge"); Clients.Client(guest.ConnectionId).recieveMessage($"Next player: {nextPlayerName}", "Judge"); }
// // GET: /UserWarehouse/Edit/5 public ActionResult Edit(int id) { UserHub userwarehouse = _userHubService.FindBy(u => u.UserHubID == id).Single(); ViewBag.UserProfileID = new SelectList(_userProfileService.GetAllUserProfile(), "UserProfileID", "UserName", userwarehouse.UserProfileID); ViewBag.WarehouseID = new SelectList(_hubService.GetAllHub(), "HubID", "Name", userwarehouse.HubID); return(PartialView(userwarehouse)); }
// // POST: /UserWarehouse/Delete/5 public ActionResult Delete(int id) { UserHub userwarehouse = _userHubService.FindBy(u => u.UserHubID == id).Single(); _userHubService.DeleteUserHub(userwarehouse); return(RedirectToAction("Index")); }
public bool DeleteUserHub(UserHub entity) { if (entity == null) { return(false); } _unitOfWork.UserHubRepository.Delete(entity); _unitOfWork.Save(); return(true); }
public void Connect() { if (Context.User.Identity.IsAuthenticated) { UserHub user = new UserHub(); user.ConnectionId = Context.ConnectionId; user.Login = Context.User.Identity.Name; Users.Add(user); } }
public void CallClient() { Clients.All.callClient("admin1"); UserHub user = Users.FirstOrDefault(x => x.Login == "petr"); if (user != null) { Clients.Client(user.ConnectionId).CallClient("admin2"); } }
//public void GetOutQueue(string login, int queueId, int countClients, int operationId) //{ // string connectionId = GetConnectionIdByLogin(login); // if (!string.IsNullOrEmpty(connectionId)) // { // Clients.Client(connectionId).enabledBtnInQueue(); // }; // Clients.All.changeCountClients(countClients, operationId); // Clients.All.removeClientFromQueue("queue_" + queueId.ToString()); //} public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled) { UserHub user = Users.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId); if (user != null) { Users.Remove(user); //IRepositoryUser _userRepository = DependencyResolver.Current.GetService<IRepositoryUser>(); //_userRepository.SetDeActiveForUser(user.Login); } return(base.OnDisconnected(stopCalled)); }
public string GetConnectionIdByLogin(string login) { UserHub user = Users.FirstOrDefault(u => u.Login == login); if (user == null) { return(""); } else { return(user.ConnectionId); } }
private UserHub BindUserOwner(HubUserViewModel hubOwnerViewModel) { if (hubOwnerViewModel == null) { return(null); } var hubOwner = new UserHub() { HubID = hubOwnerViewModel.HubID, UserProfileID = hubOwnerViewModel.UserProfileID, }; return(hubOwner); }
public ActionResult HubOwnerUpdate([DataSourceRequest] DataSourceRequest request, HubUserViewModel userhub) { if (userhub != null && ModelState.IsValid) { UserHub result = _userHubService.FindById(userhub.UserHubID); if (result != null) { result.UserProfileID = userhub.UserProfileID; result.HubID = userhub.HubID; _userHubService.EditUserHub(result); } } return(Json(new[] { userhub }.ToDataSourceResult(request, ModelState))); }
public IActionResult Get(int id) { UserHubEntity userHub = _userHubRepository.GetSingle(u => u.Id == id); if (userHub != null) { UserHub userHubDto = Mapper.Map <UserHubEntity, UserHub>(userHub); return(new OkObjectResult(userHubDto)); } else { return(NotFound()); } }
public async Task ProfileUpdated_Check() { //Arrange var hub = new UserHub(); var count = 0; hub.UserDataUpdated += model => count++; //Act var profile = new UserModel(); var json = profile.ToJson(); await hub.HandleMessageAsync(json); //Assert count.Should().Be(1); }
public void RemoveUserHub(int warehouseID, int userID) { UserProfile uProfile = _unitOfWork.UserProfileRepository.FindById(userID); var associations = from v in uProfile.UserHubs where v.HubID == warehouseID select v; if (associations.Any()) { UserHub userHub = associations.FirstOrDefault(); if (userHub != null) { DeleteById(userHub.UserHubID); } } }
public override Task OnConnected() { var username = Context.User.Identity.Name; Clients.Client(Context.ConnectionId).getMyUsername(username); var user = new UserHub { Username = Context.User.Identity.Name, ConnectionId = Context.ConnectionId }; Users.Add(user); Clients.All.listUsers(Users.Select(x => x.Username).Distinct()); return(base.OnConnected()); }
public override Task OnConnected() { var connectionId = Context.ConnectionId; var userName = Context.QueryString["username"]; var user = new UserHub { Username = userName, ConnectionId = connectionId }; var index = ConnectedUsers.FindIndex(u => u.ConnectionId == connectionId); if (index == -1) { ConnectedUsers.Add(user); return(base.OnConnected()); } ConnectedUsers[index] = user; Console.WriteLine(userName); return(base.OnConnected()); }
public ActionResult Create(UserHub userwarehouse) { if (ModelState.IsValid) { _userHubService.AddUserHub(userwarehouse); //if (userwarehouse.IsDefault == "1") //{ // var uProfile = userwarehouse.UserProfile; // uProfile.ChangeWarehouse(userwarehouse.UserWarehouseID); //} //return Json(new { success = true }); return(RedirectToAction("Index")); } ViewBag.UserProfileID = new SelectList(_userProfileService.GetAllUserProfile(), "UserProfileID", "UserName", userwarehouse.UserProfileID); ViewBag.WarehouseID = new SelectList(_hubService.GetAllHub(), "HubID", "Name", userwarehouse.HubID); return(View(userwarehouse)); }
public void AddUserHub(int warehouseID, int userID) { UserProfile uProfile = _unitOfWork.UserProfileRepository.Get(t=>t.UserProfileID==userID,null,"UserHubs").FirstOrDefault(); if (uProfile != null) { var associations = from v in uProfile.UserHubs where v.HubID == warehouseID select v; if (!associations.Any()) { var userHub = new UserHub { UserProfileID = uProfile.UserProfileID, HubID = warehouseID }; AddUserHub(userHub); } } }
public void AddUserHub(int warehouseID, int userID) { UserProfile uProfile = _unitOfWork.UserProfileRepository.Get(t => t.UserProfileID == userID, null, "UserHubs").FirstOrDefault(); if (uProfile != null) { var associations = from v in uProfile.UserHubs where v.HubID == warehouseID select v; if (!associations.Any()) { var userHub = new UserHub { UserProfileID = uProfile.UserProfileID, HubID = warehouseID }; AddUserHub(userHub); } } }
public ActionResult Edit(UserHub userwarehouse) { if (ModelState.IsValid) { _userHubService.EditUserHub(userwarehouse); //db.UserHubs.Attach(userwarehouse); //db.ObjectStateManager.ChangeObjectState(userwarehouse, EntityState.Modified); ////if (userwarehouse.IsDefault == "1") ////{ //// var uProfile = userwarehouse.UserProfile; //// uProfile.ChangeWarehouse(userwarehouse.UserWarehouseID); ////} //db.SaveChanges(); //return RedirectToAction("Index"); return(Json(new { success = true })); } ViewBag.UserProfileID = new SelectList(_userProfileService.GetAllUserProfile(), "UserProfileID", "UserName", userwarehouse.UserProfileID); ViewBag.WarehouseID = new SelectList(_hubService.GetAllHub(), "HubID", "Name", userwarehouse.HubID); return(View(userwarehouse)); }
public IActionResult Patch(int id, [FromBody] UserHub userHub) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } UserHubEntity userHubEntity = _userHubRepository.GetSingle(id); if (userHubEntity == null) { return(NotFound()); } else { userHubEntity.UserId = userHub.UserId; userHubEntity.HubId = userHub.HubId; _userHubRepository.Commit(); } var userDto = Mapper.Map <UserHubEntity, UserHub>(userHubEntity); return(new OkObjectResult(userDto)); }
public bool EditUserHub(UserHub entity) { _unitOfWork.UserHubRepository.Edit(entity); _unitOfWork.Save(); return true; }
public FrontServiceClient() { UserHub = new UserHub(); NotesHub = new NotesHub(); AuthenticationHub = new AuthenticationHub(); }
public async Task CallAccepted(UserHub calledUser) { var currentUser = _connectionService.GetHubUserByName(Context.User.Identity.Name); await Clients.Client(calledUser.ConnectionId).SendAsync("CallAccepted", currentUser); }
public AccountController() { _hub = new UserHub(); }
private void dependency_OnChange(object sender, SqlNotificationEventArgs e) { UserHub.Show(); }
public bool AddUserHub(UserHub entity) { _unitOfWork.UserHubRepository.Add(entity); _unitOfWork.Save(); return(true); }
public bool EditUserHub(UserHub entity) { _unitOfWork.UserHubRepository.Edit(entity); _unitOfWork.Save(); return(true); }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager) { UserManager = userManager; SignInManager = signInManager; _hub = new UserHub(); }
public bool AddUserHub(UserHub entity) { _unitOfWork.UserHubRepository.Add(entity); _unitOfWork.Save(); return true; }
private static void InitializeSchedules() { WasteManagement wasteMgmt01 = new WasteManagement { Name = "AffaldPlus" }; if (!context.WasteManagements.Any()) { context.WasteManagements.Add(wasteMgmt01); } User user01 = new User { FirstName = "Chris", LastName = "Sakellarios" }; User user02 = new User { FirstName = "Charlene", LastName = "Campbell" }; User user03 = new User { FirstName = "Mattie", LastName = "Lyons" }; User user04 = new User { FirstName = "Kelly", LastName = "Alvarez" }; User user05 = new User { FirstName = "Charlie", LastName = "Cox" }; User user06 = new User { FirstName = "Megan", LastName = "Fox" }; if (!context.Users.Any()) { context.Users.Add(user01); context.Users.Add(user02); context.Users.Add(user03); context.Users.Add(user04); context.Users.Add(user05); context.Users.Add(user06); } Hub hub01 = new Hub { Name = "Canadien Hubs", Location = "G4", WasteManagementId = wasteMgmt01.Id }; Hub hub02 = new Hub { Name = "Hubsa", Location = "J4", WasteManagementId = wasteMgmt01.Id }; Hub hub03 = new Hub { Name = "Downtown", Location = "C3", WasteManagementId = wasteMgmt01.Id }; Hub hub04 = new Hub { Name = "Seje Hub", Location = "D2", WasteManagementId = wasteMgmt01.Id }; Hub hub05 = new Hub { Name = "Wazzup Hub", Location = "A1", WasteManagementId = wasteMgmt01.Id }; if (!context.Hubs.Any()) { context.Hubs.Add(hub01); context.Hubs.Add(hub02); context.Hubs.Add(hub03); context.Hubs.Add(hub04); context.Hubs.Add(hub05); } Fraction fraction01 = new Fraction { HubId = hub01.Id, UserId = user01.Id, IsClean = true, Weight = 0.73 }; Fraction fraction02 = new Fraction { HubId = hub02.Id, UserId = user02.Id, IsClean = true, Weight = 0.5 }; Fraction fraction03 = new Fraction { HubId = hub03.Id, UserId = user03.Id, IsClean = true, Weight = 1.6 }; Fraction fraction04 = new Fraction { HubId = hub04.Id, UserId = user01.Id, IsClean = true, Weight = 0.73 }; Fraction fraction05 = new Fraction { HubId = hub05.Id, UserId = user04.Id, IsClean = false, Weight = 0.73 }; Fraction fraction06 = new Fraction { HubId = hub01.Id, UserId = user05.Id, IsClean = true, Weight = 0.73 }; Fraction fraction07 = new Fraction { HubId = hub01.Id, UserId = user05.Id, IsClean = true, Weight = 0.73 }; Fraction fraction08 = new Fraction { HubId = hub01.Id, UserId = user01.Id, IsClean = false, Weight = 0.73 }; Fraction fraction09 = new Fraction { HubId = hub02.Id, UserId = user02.Id, IsClean = true, Weight = 0.73 }; Fraction fraction10 = new Fraction { HubId = hub03.Id, UserId = user03.Id, IsClean = true, Weight = 0.73 }; Fraction fraction11 = new Fraction { HubId = hub04.Id, UserId = user01.Id, IsClean = true, Weight = 0.73 }; if (!context.Fractions.Any()) { context.Fractions.Add(fraction01); context.Fractions.Add(fraction02); context.Fractions.Add(fraction03); context.Fractions.Add(fraction04); context.Fractions.Add(fraction05); context.Fractions.Add(fraction06); context.Fractions.Add(fraction07); context.Fractions.Add(fraction08); context.Fractions.Add(fraction09); context.Fractions.Add(fraction10); context.Fractions.Add(fraction11); } UserHub userHub01 = new UserHub { HubId = hub01.Id, UserId = user01.Id }; UserHub userHub02 = new UserHub { HubId = hub02.Id, UserId = user02.Id }; UserHub userHub03 = new UserHub { HubId = hub03.Id, UserId = user03.Id }; UserHub userHub04 = new UserHub { HubId = hub04.Id, UserId = user01.Id }; UserHub userHub05 = new UserHub { HubId = hub05.Id, UserId = user04.Id }; UserHub userHub06 = new UserHub { HubId = hub01.Id, UserId = user05.Id }; if (!context.UserHubs.Any()) { context.Add(userHub01); context.Add(userHub02); context.Add(userHub03); context.Add(userHub04); context.Add(userHub05); context.Add(userHub06); } context.SaveChanges(); }
// // GET: /UserWarehouse/Details/5 public ViewResult Details(int id) { UserHub userwarehouse = _userHubService.FindBy(u => u.UserHubID == id).Single(); return(View(userwarehouse)); }
public void LoginHubUser(UserHub user) { Connections.HubUsers.AddOrUpdate(user.UserName, user, (k, v) => user); }