private async Task <UpdateToggleTagsResponse> ModifyTags(ToggleLocator locator, Action <Toggle> modify)
        {
            var toggle = await locator.LocateAggregate(_session);

            modify(toggle);
            await _session.Save(toggle);

            return(new UpdateToggleTagsResponse
            {
                Tags = toggle.Tags.ToArray()
            });
        }
示例#2
0
        public async Task <ChangeToggleDescriptionResponse> Handle(ChangeToggleDescriptionRequest request, CancellationToken cancellationToken)
        {
            var toggle = await request.Locator.LocateAggregate(_session);

            toggle.ChangeDescription(request.Editor, request.Description);

            await _session.Save(toggle);

            return(new ChangeToggleDescriptionResponse
            {
                ToggleID = toggle.ID,
                Description = toggle.Description
            });
        }
示例#3
0
        public async Task <CreateTogglesResponse> Handle(CreateToggleRequest message, CancellationToken cancellationToken)
        {
            var newToggle = Toggle.CreateNew(
                message.Creator,
                message.Name,
                message.Description);

            await _session.Save(newToggle);

            return(new CreateTogglesResponse
            {
                Toggle = newToggle.ToView()
            });
        }
        public async Task <RemoveToggleConditionResponse> Handle(RemoveToggleConditionRequest message, CancellationToken cancellationToken)
        {
            var toggle = await message.Locator.LocateAggregate(_session);

            toggle.RemoveCondition(message.Editor, message.ConditionId);

            await _session.Save(toggle);

            return(new RemoveToggleConditionResponse
            {
                ToggleID = toggle.ID,
                Conditions = toggle.Conditions
            });
        }
示例#5
0
        public async Task <RenameToggleResponse> Handle(RenameToggleRequest request, CancellationToken cancellationToken)
        {
            var toggle = await request.Locator.LocateAggregate(_session);

            toggle.Rename(request.Editor, request.Name);

            await _session.Save(toggle);

            return(new RenameToggleResponse
            {
                ToggleID = toggle.ID,
                Name = toggle.Name
            });
        }
示例#6
0
        public async Task <AddToggleConditionResponse> Handle(AddToggleConditionRequest message, CancellationToken cancellationToken)
        {
            var toggle = await message.Locator.LocateAggregate(_session);

            var added = toggle.AddCondition(message.Editor, message.Properties);

            await _session.Save(toggle);

            return(new AddToggleConditionResponse
            {
                ToggleID = toggle.ID,
                Condition = toggle.Condition(added)
            });
        }
        public async Task <ChangeConditionModeResponse> Handle(ChangeConditionModeRequest message, CancellationToken cancellationToken)
        {
            var toggle = await message.Locator.LocateAggregate(_session);

            if (message.Mode == ConditionModes.All)
            {
                toggle.EnableOnAllConditions(message.Editor);
            }
            else
            {
                toggle.EnableOnAnyCondition(message.Editor);
            }

            await _session.Save(toggle);

            return(new ChangeConditionModeResponse
            {
                ConditionMode = toggle.ConditionMode,
                Conditions = toggle.Conditions
            });
        }
        public async Task <WriteStatisticsResponse> Handle(WriteStatisticsRequest message, CancellationToken cancellationToken)
        {
            await _session.Save(new EventAdaptor <Statistic>(message.Statistics, CreateEvent));

            return(new WriteStatisticsResponse());
        }
示例#9
0
 public void Save(IEntity <string> entity)
 {
     _outsideSession.Save(entity);
 }