Ejemplo n.º 1
0
        public void Handle(EmailUserEvent evt)
        {
            TestCFContext db     = new TestCFContext();
            var           entity = db.Set <TestUser>().Find(evt.UserID);

            entity.Email = evt.Email;
            db.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Handle(RenameUserEvent evt)
        {
            TestCFContext db     = new TestCFContext();
            var           entity = db.Set <TestUser>().Find(evt.UserID);

            entity.UserName = evt.UserName;
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void Handle(CreateUserEvent evt)
        {
            TestCFContext db     = new TestCFContext();
            var           entity = new TestUser
            {
                Email    = evt.Email,
                UserName = evt.UserName,
            };

            db.Entry(entity);
            db.Set <TestUser>().Add(entity);
            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public void Execute(EditUserCommand command)
        {
            TestCFContext db        = new TestCFContext();
            var           aggregate = db.Set <TestUser>().Find(command.UserID);

            if (!string.IsNullOrWhiteSpace(command.UserName))
            {
                aggregate.ChangeUserName(command.UserName);
            }
            if (!string.IsNullOrWhiteSpace(command.Email))
            {
                aggregate.ChangeEmail(command.Email);
            }
            Console.WriteLine(DateTime.Now + "编辑" + command.UserName);
        }