コード例 #1
0
        public async Task <OperationResult> UpsertProjectAsync(IUpsertProject command)
        {
            var projectUri = command.ProjectId.ToKotoriProjectUri();

            var p = await FindProjectAsync(command.Instance, projectUri).ConfigureAwait(false);

            var isNew = p == null;

            if (p != null &&
                command.CreateOnly)
            {
                throw new KotoriProjectException(command.ProjectId, "Project already exists.");
            }

            if ((command.CreateOnly) ||
                (!command.CreateOnly && p == null))
            {
                p = new Entities.Project(command.Instance, command.Name, projectUri.ToString());
            }
            else
            {
                p.Identifier = projectUri.ToString();
                p.Name       = command.Name;
            }

            var project = await UpsertProjectAsync(p).ConfigureAwait(false);

            var result = new OperationResult(project, isNew);

            return(result);
        }
コード例 #2
0
ファイル: DocumentDb.cs プロジェクト: kotorihq/kotori-core
 async Task <Entities.Project> UpsertProjectAsync(Entities.Project project)
 {
     return(await _repoProject.UpsertAsync(project).ConfigureAwait(false));
 }