private async Task <bool> CreateAggregateSpreadsheet(Domain.Agent agent) { var spreadsheet = CreateSpreadsheetForTrackingInquiry(agent, inquiryAggrigateHeaders.ToList(), InquiryType.Aggregate); agent.AgentSpreadsheet.AggregateSpreadsheetUrl = spreadsheet.SpreadsheetUrl; agent.AgentSpreadsheet.AggregateSpreadsheetShareableUrl = spreadsheet.SpreadsheetUrl; agent.AgentSpreadsheet.AggregateSpreadsheetId = spreadsheet.SpreadsheetId; agent.AgentSpreadsheet.AggregateSpreadsheetName = agent.GetSpreadsheetName(Enum.GetName(typeof(InquiryType), InquiryType.Aggregate)); var filter = Builders <Agent> .Filter.Eq("Id", agent.Id); var update = Builders <Agent> .Update .Set("AgentSpreadsheet", agent.AgentSpreadsheet) .CurrentDate("UpdatedDate"); await agentRepository.Collection .UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = true }); agent.CreateSpreadsheet(InquiryType.Aggregate); await mediator.DispatchDomainEventsAsync(agent); return(true); }