public async Task <Tuple <ErrorResponse, Template> > CreateProjectAssociationAsync(string templateId, string projectId) { if (projectId == null || templateId == null) { return(new Tuple <ErrorResponse, Template>(new ErrorResponse(400.2, $"Neither the 'Template Id' nor the 'Project Id' can be null."), null)); } else if (templateId.Length != 24) { return(new Tuple <ErrorResponse, Template>(new ErrorResponse(400.2, $"The Template Id string has to be in the BSON Id format."), null)); } await repository.AddProjectByTemplateIdAsync(templateId, projectId); var updatedTemplate = await repository.GetByIdAsync(templateId); await eventSourceManager.UpdateTemplateEvent(updatedTemplate); return(new Tuple <ErrorResponse, Template>(null, updatedTemplate)); }