Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateTrack(string moniker, int id, [FromBody] TalkViewModel model)
        {
            try
            {
                var talk  = _repo.GetTalk(id);
                var track = _repo.GetTracks(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(talk));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to update track: {0}", ex);
            }

            return(BadRequest("Couldn't update talk."));
        }
Ejemplo n.º 2
0
 public IActionResult Get(string moniker)
 {
     return(Ok(_repo.GetTracks(moniker)));
 }