示例#1
0
            public async Task <Result> Handle(Command request, CancellationToken cancellationToken)
            {
                var dbGuild = context.Guilds.FirstOrDefaultAsync(guild => guild.Id == request.GuildId);

                if (dbGuild.IsNull())
                {
                    throw new NotFoundException(request.GuildId, typeof(Guild));
                }

                var uploadRequest = mapper.Map <AudioFileDto>(request);

                var audioUrl = await blobStorageService.UploadAudioFileForGuild(uploadRequest);

                var dbSound = mapper.Map <Sound>(request);

                dbSound.Url = audioUrl;

                await context.AddAsync(dbSound);

                await context.SaveChangesAsync();

                var result = mapper.Map <Result>(dbSound);

                return(result);
            }