Esempio n. 1
0
        public async Task Seed()
        {
            output.WriteVerboseMessage(string.Empty);
            output.WriteVerboseMessage($"=== Service lifecycle info {nameof(MountEverestBaseCampTrackNextSteps)} ===");
            output.WriteVerboseMessage($"{nameof(IActionService)} unique value: {actionService.GetHashCode()}");
            output.WriteVerboseMessage($"{nameof(IOutputSink)} unique value: {output.GetHashCode()}");
            output.WriteVerboseMessage($"{nameof(ISomeSingletonService)} unique value: {someSingletonService.GetHashCode()}");
            output.WriteVerboseMessage($"=== Service lifecycle info {nameof(MountEverestBaseCampTrackNextSteps)} ===");
            output.WriteVerboseMessage(string.Empty);

            var project = await MountEverestBaseCampTrack.GetMountEverestBaseCampTrackProject();

            var actionNames = new[] { "Check visa requirements", "See which equipment can be borrowed in Kathmandu" };
            var actions     = new List <ActionDto>();

            foreach (var actionName in actionNames)
            {
                actions.Add((await actionService.CreateOrUpdate(new ActionDto {
                    Title = actionName, ProjectId = project.Id
                })).Value);
            }

            var doneList = (await actionListService.CreateOrUpdate(new ActionListDto {
                Name = "Next steps"
            })).Value;

            foreach (var action in actions)
            {
                await actionService.MoveToList(action.Id, doneList.Id);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([FromBody] ActionDto value)
        {
            Log.Warning("Action create {@value}", value);

            if (!value.RepresentsNewEntity)
            {
                return(BadRequest());
            }

            var result = await _actionService.CreateOrUpdate(value);

            if (!result.IsOk())
            {
                return(FromServiceResult(result));
            }

            return(CreatedAtRoute(Routes.GetActionById, new { id = result.Value.Id }, result.Value));
        }