public async Task <IActionResult> UpdateTrack(string moniker, int id, [FromBody] TalkViewModel model)
        {
            try
            {
                var talk = await _repo.GetTalkAsync(id);

                var track = (await _repo.GetTracksAsync(moniker)).Where(r => r.Name == model.Track).FirstOrDefault();
                if (track == null || talk == null)
                {
                    return(NotFound("Cannot find talk."));
                }
                talk.Track = track;

                await _repo.SaveChangesAsync();

                return(Ok(true));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to update track: {0}", ex);
            }

            return(BadRequest("Couldn't update talk."));
        }
示例#2
0
 public async Task <IActionResult> Get(string moniker)
 {
     return(Ok(await _repo.GetTracksAsync(moniker)));
 }