コード例 #1
0
        public async Task <IActionResult> Create(
            TeamRequestV1 payload,
            ApiVersion version)
        {
            var dto    = payload.MapCreatedToDto(DateTimeOffset.UtcNow, Guid.NewGuid());
            var result = await teamsStore.CreateTeamAsync(dto);

            return(CreatedAtRoute(
                       nameof(GetOne),
                       new
            {
                version = $"{version}",
                id = result.Id
            }, result.MapFromDto()));
        }
コード例 #2
0
        public static Team MapCreatedToDto(
            [DisallowNull] this TeamRequestV1 request,
            DateTimeOffset created,
            Guid id)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(new Team
            {
                Id = id,
                Updated = created,
                Name = request.Name
            });
        }