Ejemplo n.º 1
0
        public async override Task Execute(SubscriptionPlanUpdateCommand input, User?user)
        {
            var plan = await repo.FindById(input.Id);

            if (plan == null)
            {
                throw new EntityNotFoundException();
            }

            plan.Description = input.Description;
            plan.RoleId      = input.RoleId;

            await repo.Update(plan);
        }
Ejemplo n.º 2
0
        // Don't delete. It's used twice in the app layer.
        public async Task <List <SubscriptionPlan> > RefreshPlans()
        {
            var plans = await gateway.GetAll();

            foreach (var plan in plans)
            {
                var existingPlan = await repo.FindById(plan.Id);

                if (existingPlan == null)
                {
                    await repo.Add(plan);
                }
                else
                {
                    // We don't want to wipe out some extra data we keep on our end. (Description, RoleId)
                    existingPlan.Name   = plan.Name;
                    existingPlan.Prices = plan.Prices;

                    await repo.Update(existingPlan);
                }
            }

            return(plans);
        }