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); }
async Task <Entities.Project> UpsertProjectAsync(Entities.Project project) { return(await _repoProject.UpsertAsync(project).ConfigureAwait(false)); }