public async Task <Unit> Handle(CreateTeam request, CancellationToken cancellationToken) { // TODO: implement handling // create team via graph api // put information about team creation to db try { // creating team in MS Graph via API Guid teamId = await _graphClient.CreateTeamAsync( request.Discipline, request.Division, request.ContingentUnit, request.Year, request.Semester, request.Members // optional ); // if everything ok, we know id of the team => event happened // we post it to database await _integrationRepository.InsertCreateTeamEventAsync( request.Discipline, request.Division, request.ContingentUnit, request.Year, request.Semester); // new we need to add create members events: if (request.Members != null) { await _integrationRepository.InsertRangeAddMemberEventAsync( request.Members .Select(x => (x, teamId)) .ToArray() ); } } catch (Exception) { // ? we might need some error handling and logging which should be placed here throw; } return(Unit.Value); }