public IdentityService(IServiceProvider provider) { _logger = provider.GetService <ILoggerFactory>()? .CreateLogger <IdentityService>(); _userManager = provider.GetRequiredService <UserManager <ChatIdentityUser> >(); _signInManager = provider.GetRequiredService <SignInManager <ChatIdentityUser> >(); _userRepo = provider.GetRequiredService <IUserRepository>(); _chatroomRepo = provider.GetRequiredService <IChatroomRepository>(); _eventBus = provider.GetRequiredService <IEventBus>(); Subcriptions.Add(_eventBus.GetEventStream <UserSignupEvent>() .Subscribe(async e => await AddNewUserToGlobalChatroom(e))); Subcriptions.Add(_eventBus.GetEventStream <UserEnteredEvent>() .Subscribe(async e => { var room = await _chatroomRepo.GetByIdAsync(e.ChatroomId); var user = await _userRepo.GetByIdAsync(e.UserId); user.UserChatrooms.Add(room.UserChatrooms.First(uc => uc.UserId == e.UserId)); await _userRepo.SaveChangesAsync(); })); Subcriptions.Add(_eventBus.GetEventStream <UserLeftEvent>() .Subscribe(async e => { var room = await _chatroomRepo.GetByIdAsync(e.ChatroomId); var user = await _userRepo.GetByIdAsync(e.UserId); user.UserChatrooms.Remove(user.UserChatrooms.First(uc => uc.ChatroomId == e.ChatroomId)); await _userRepo.SaveChangesAsync(); })); // EnsureAddAdmin().Wait(); }
public ChatroomController(IChatroomRepository chatroomRepository, IChatroomFactory chatroomFactory, IServiceBus serviceBus) { _chatroomRepository = chatroomRepository; _chatroomFactory = chatroomFactory; _serviceBus = serviceBus; }
public ChatService(UserManager <User> userManager, IMapper mapper, IChatroomRepository chatroomRepository, IUserChatroomRepository userChatroomRepository, IChatroomMessageRepository chatroomMessageRepository) { this.userManager = userManager; this.mapper = mapper; this.userChatroomRepository = userChatroomRepository; this.chatroomRepository = chatroomRepository; this.chatroomMessageRepository = chatroomMessageRepository; }
public ChatroomService(IChatroomRepository repository , IChatroomMappingService mappingService , ApplicationDbContext context) { _repository = repository ?? throw new ArgumentNullException(nameof(repository)); _mappingService = mappingService ?? throw new ArgumentNullException(nameof(mappingService)); _context = context ?? throw new ArgumentNullException(nameof(context)); }
public ChatroomService(IServiceProvider provider) { _logger = provider.GetService <ILoggerFactory>()? .CreateLogger <ChatroomService>(); _chatroomRepo = provider.GetRequiredService <IChatroomRepository>(); _userRepo = provider.GetRequiredService <IUserRepository>(); _eventBus = provider.GetRequiredService <IEventBus>(); Subcriptions.Add(_eventBus.GetEventStream <BecameFriendsEvent>().Subscribe( async e => await GetOrAddP2PChatroom(e.UserId, e.User2Id))); }
public UserClientService(IServiceProvider provider) { _logger = provider.GetService <ILoggerFactory>()? .CreateLogger <UserClientService>(); _chatroomRepo = provider.GetRequiredService <IChatroomRepository>(); _eventBus = provider.GetRequiredService <IEventBus>(); Subcriptions.Add(_eventBus.GetEventStream <ChatroomEvent>() .Select(ChatroomEventMapper.Map) .Where(m => m?.Content != null) .Subscribe(async m => await ForwardMessage(m))); }
public Server(IServiceProvider provider) { _provider = provider; _logger = provider.GetService <ILoggerFactory>()?.CreateLogger("Chat.Server"); _eventBus = provider.GetRequiredService <IEventBus>(); var eventLogger = provider.GetService <ILoggerFactory>()?.CreateLogger("Chat.Server.Events"); _eventBus.GetEventStream <DomainEvent>().Subscribe(e => eventLogger.LogInformation( e.GetType().Name + " " + JsonConvert.SerializeObject(e))); _userRepo = provider.GetRequiredService <IUserRepository>(); _chatroomRepo = provider.GetRequiredService <IChatroomRepository>(); _messageRepo = provider.GetRequiredService <IMessageRepository>(); _identityService = provider.GetRequiredService <IdentityService>(); _chatroomService = provider.GetRequiredService <ChatroomService>(); _messageService = provider.GetRequiredService <MessageService>(); _userClientService = provider.GetRequiredService <UserClientService>(); _chatroomService.EnsureGlobalChatroomCreated(); }
internal ChatroomApplication(IServiceProvider provider) { _provider = provider; _userRepo = provider.GetRequiredService <IUserRepository>(); _chatroomRepo = provider.GetRequiredService <IChatroomRepository>(); }
public ChatroomController(IChatroomRepository chatroomRepository, ILogger <ChatroomController> logger) { _logger = logger; _chatroomRepository = chatroomRepository; }
public ChatroomBusiness(IChatroomRepository chatroomRepository, IMapper mapper) { this.chatroomRepository = chatroomRepository; this.mapper = mapper; }