public async Task <IActionResult> CreateTrack([FromForm] AddTrackInput addTrackInput)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            await trackCrud.AddTrack(addTrackInput);

            return(Ok());
        }
Exemple #2
0
        public async Task <AddTrackPayload> AddTrackAsync(
            AddTrackInput input,
            [ScopedService] ApplicationDbContext context,
            CancellationToken cancellationToken)
        {
            var track = new Track {
                Name = input.Name
            };

            context.Tracks.Add(track);

            await context.SaveChangesAsync(cancellationToken);

            return(new AddTrackPayload(track));
        }