Esempio n. 1
0
        private bool IsNewUser(Budget.Users.Domain.WriteModel.User user)
        {
            var newSubscriptions = user.NewChanges.Where(
                @event => @event.GetType() == typeof(UserSubscribed)
                );

            return(newSubscriptions.Any());
        }
Esempio n. 2
0
        public async Task Save(Budget.Users.Domain.WriteModel.User user)
        {
            var dbUser = new User(user);

            if (IsNewUser(user))
            {
                await Users.InsertOneAsync(dbUser);
            }
            else
            {
                await Users.FindOneAndReplaceAsync <User>(u => u.Id == dbUser.Id, dbUser);
            }
        }
Esempio n. 3
0
        public async Task <Budget.Users.Domain.WriteModel.User> Get(Guid id)
        {
            Budget.Users.Domain.WriteModel.User user = null;
            var search = await Users.FindAsync <User>(u => u.Id == id);

            var dbUser = search.FirstOrDefault();

            if (dbUser != null)
            {
                user = UserFactory.Load(id, dbUser.Changes);
            }

            return(user);
        }
Esempio n. 4
0
 public User(Budget.Users.Domain.WriteModel.User user)
 {
     Id      = user.Id;
     Changes = user.Changes;
 }