示例#1
0
        public bool Publish(Product product)
        {
            if (product.IsPublished)
            {
                return(false);
            }

            product.IsPublished = true;

            _database.SaveChanges();

            Event.Raise(new ProductPublished(product), _instance);

            return(true);
        }
        protected override void Execute(IOrderEvent @event, ActivityContext context)
        {
            var config = context.Config as ChangeSavingPointsActivityConfig;

            if (config == null)
            {
                return;
            }

            var customer = GetCustomer(@event);

            if (customer == null)
            {
                return;
            }

            if (config.Action == SavingPointAction.Increase)
            {
                customer.SavingPoints += config.Amount;
            }
            else
            {
                customer.SavingPoints -= config.Amount;
            }

            _database.SaveChanges();
        }