C#C
C#3y ago
SWEETPONY

❔ How to rewrite this to linq without multiple select?

 private async Task OnChannelsRegister(
     IDeliveryHandlerContext context,
     ChannelsRegisterArguments arguments )
 {
     var registerDtos = new List<ServiceRegisterDto>();
     var mutationDtos = new List<ServiceMutationDto>();
     var startDtos = new List<ServiceStartDto>();

     foreach (var channel in arguments.Items)
     {
         var registerDto = new ServiceRegisterDto
         {
             PackageName = channel.Type.Name,
             Title = channel.Type.Name,
             Description = channel.Type.Description
         };

         registerDtos.Add(registerDto);

         var mutationDto = new ServiceMutationDto
         {
             Name = channel.Type.Name,
             Title = channel.Type.Title,
             Description = channel.Type.Description,
             Configuration = channel.Configuration
         };

         mutationDtos.Add( mutationDto );

         var startDto = new ServiceStartDto
         {
             Name = channel.Type.Name
         };

         startDtos.Add( startDto );
     }

     await _scmClient.ServicesRegister(new ServicesRegisterArguments( registerDtos));

     await _scmClient.ServicesModify(new ServicesModifyArguments( mutationDtos));

     await _scmClient.ServicesStart(new ServicesStartArguments( startDtos));
 }
Was this page helpful?