Exemplo n.º 1
0
        public async Task <ProgramRelease> CreateAsync(CreateProgramReleaseRequest request, ISecurityContext context)
        {
            Ensure.NotNull(request, nameof(request));
            Ensure.NotNull(context, nameof(request));

            if (request.Version == default)
            {
                throw new ArgumentException("Must be be default", nameof(request.Version));
            }

            // Create the package ----------------------
            var package = await packageManager.CreateAsync(new CreatePackageRequest(
                                                               programId      : request.Program.Id,
                                                               programVersion : request.Version,
                                                               stream         : request.Package.Stream,
                                                               format         : request.Package.Format,
                                                               sha256         : request.Package.Sha256,
                                                               dekId          : request.Package.DekId
                                                               ), context);

            // Create the release ----------------------
            var release = await releaseService.CreateAsync(new RegisterProgramReleaseRequest(
                                                               program    : request.Program,
                                                               version    : request.Version,
                                                               commitId   : request.Commit?.Id ?? 0L,
                                                               buildId    : request.Build?.Id,
                                                               creatorId  : context.UserId.Value,
                                                               properties : request.Program.Properties
                                                               ));

            #region Logging

            await eventLog.CreateAsync(new Event(
                                           action   : "create",
                                           resource : "program#" + release.ProgramId + "@" + release.Version,
                                           userId   : context.UserId
                                           ));

            #endregion

            return(release);
        }