public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: { var newUser = new UserProjection() { UserEmail = model.Email, UserName = model.Email }; OnlineUsersTracker.AddOnlineUser(newUser); return(RedirectToLocal(returnUrl)); } case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
internal static void AddOnlineUser(UserProjection projection) { var user = MvcApplication.OnlineUsers.FirstOrDefault(u => u.Email.Equals(projection.Email)); if (user == null) { MvcApplication.OnlineUsers.Add(projection); GamesHubContext.Clients.All.userJoinedSite(projection); } }
internal static void RemoveOnlineUser(UserProjection projection) { var user = MvcApplication.OnlineUsers.FirstOrDefault(u => u.Email.Equals(projection.Email)); if (user != null) { MvcApplication.OnlineUsers.Remove(user); GamesHubContext.Clients.All.userLeftSite(projection); } }
public void Remove(UserProjection entity) { var oldState = _context.UsersProjection .OrderByDescending(or => or.RowVersion) .FirstOrDefault(b => b.Id.Equals(entity.Id) && b.RowVersion.Equals(entity.RowVersion)); _context.UsersProjection.Remove(entity); }
private UserProjection Convert(UserCreated @event) { var entity = new UserProjection { UserId = @event.UserId, UserName = @event.UserName, Details = $"User {@event.UserName} assigned to the group {@event.UserGroup.Name}." }; return(entity); }
public UserProjection Get(IEntityIdentity <Guid> id) { var user = _context.Users.FindById(id.Identity); if (user == null) { return(UserProjection.Empty()); } return(user); }
public UserProjection Get(UserId id) { var user = _context.UsersProjection .FirstOrDefault(ac => ac.Id.Equals(id.Value)); if (user == null) { UserProjection.Empty(); } return(user); }
protected override void ExecuteHandle(UserAddedEvent @event) { var projection = new UserProjection( @event.Id.Value, @event.Name.Value, @event.Cnpj.Value, @event.CommercialEmail.Value, @event.Version.Value); _projectSession.Repository.Add(projection); _projectSession.SaveChanges(); }
protected override async Task ExecuteHandle(UserAddedEvent @event, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested == false) { var projection = new UserProjection( @event.Id.Value, @event.Name.Value, @event.Version.Value); _projectSession.Repository.Add(projection); await _projectSession.SaveChangesAsync(cancellationToken); } }
public ActionResult LogOff() { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); var userName = HttpContext.User.Identity.Name; var userProjection = new UserProjection() { UserEmail = userName, UserName = userName }; OnlineUsersTracker.RemoveOnlineUser(userProjection); return(RedirectToAction("Index", "Home")); }
public void Add(UserProjection entity) { var oldState = _context.UsersProjection.FirstOrDefault(b => b.Id == entity.Id); if (oldState == null) { _context.UsersProjection.Add(entity); } else { _context.Entry(oldState).CurrentValues.SetValues(entity); } }
public void Initialize() { // Configuration Parameters var eventDatabaseConnectionString = "Data Source=localhost;Initial Catalog=eventway-sample-db;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; var projectionMetadataDatabaseConnectionString = eventDatabaseConnectionString; var cosmosDbEndpoint = "https://localhost:8081"; // This is the default endpoint for local emulator-instances of the Cosmos DB var cosmosDbAuthKey = "<REPLACE WITH YOUR COSMOS DB AUTH KEY>"; var cosmosDbDatabaseId = "eventway-sample-db"; var cosmosDbCollectionId = "projections"; var offerThroughput = 10000; var noOfPartitions = 1000; // Event Repository var eventRepository = new SqlServerEventRepository(eventDatabaseConnectionString); // Projection Metadata Repository var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(projectionMetadataDatabaseConnectionString); // Query Model Repository var queryModelRepository = new DocumentDbQueryModelRepository(cosmosDbDatabaseId, cosmosDbCollectionId, offerThroughput, noOfPartitions, cosmosDbEndpoint, cosmosDbAuthKey); queryModelRepository.Initialize(); // Event Listener var eventListener = new BasicEventListener(); // Aggregate services var aggregateFactory = new DefaultAggregateFactory(); var aggregateRepository = new AggregateRepository(eventRepository, aggregateFactory); var aggregateStore = new AggregateStore(aggregateRepository, eventListener); // PROJECTIONS UserProjection = new UserProjection( eventRepository, eventListener, queryModelRepository, projectionMetadataRepository); // APPLICATION SERVICES UserApplicationService = new UserApplicationService( aggregateStore, queryModelRepository); // Start listening for events UserProjection.Listen(); }
public void Initialize() { // Configuration Parameters var eventDatabaseConnectionString = "Data Source=localhost;Initial Catalog=eventway;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; var projectionMetadataDatabaseConnectionString = eventDatabaseConnectionString; var cosmosDbEndpoint = "https://localhost:8081"; // This is the default endpoint for local emulator-instances of the Cosmos DB var cosmosDbAuthKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; var cosmosDbDatabaseId = "eventway"; var cosmosDbCollectionId = "projections"; var offerThroughput = 10000; var noOfPartitions = 1000; // Event Repository var eventRepository = new SqlServerEventRepository(eventDatabaseConnectionString); // Projection Metadata Repository var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(projectionMetadataDatabaseConnectionString); // Query Model Repository var queryModelRepository = new CosmosDbQueryModelRepository(cosmosDbDatabaseId, cosmosDbCollectionId, offerThroughput, noOfPartitions, cosmosDbEndpoint, cosmosDbAuthKey); queryModelRepository.Initialize(); // Event Listener var eventListener = new BasicEventListener(); // Aggregate services var aggregateFactory = new DefaultAggregateFactory(); var aggregateRepository = new AggregateRepository(eventRepository, aggregateFactory); var aggregateStore = new AggregateStore(aggregateRepository, eventListener); // PROJECTIONS UserProjection = new UserProjection( eventRepository, eventListener, queryModelRepository, projectionMetadataRepository); // APPLICATION SERVICES UserApplicationService = new UserApplicationService( aggregateStore, queryModelRepository); // Start listening for events UserProjection.Listen(); }
public Task <string> RenderAccountResetPasswordAsync(DomainUser user, string link) => Compose( RenderHeaderAsync(), RenderTemplateAsync("reset-password", new { User = UserProjection.Project(user), Link = link }), RenderFooterAsync() );
public Task <string> RenderAccountConfirmationAsync(DomainUser user, string link) => Compose( RenderHeaderAsync(), RenderTemplateAsync("account-confirmation", new { User = UserProjection.Project(user), Link = link }), RenderFooterAsync() );
public void Remove(UserProjection entity) { _context.Users.Delete(entity.Id); }
public long Insert(UserProjection projection) { _databaseContext.ActiveUsers.Insert(projection); return(projection.UserId); }
public void Add(UserProjection entity) { _context.Users.Upsert(entity); }