public async Task <IActionResult> UpdateRoom(string moniker, int id, [FromBody] TalkViewModel model) { try { var talk = await _repo.GetTalkAsync(id); var room = (await _repo.GetRoomsAsync(moniker)).Where(r => r.Name == model.Room).FirstOrDefault(); if (room == null || talk == null) { return(NotFound("Cannot find talk.")); } talk.Room = room; await _repo.SaveChangesAsync(); return(Ok(true)); } catch (Exception ex) { _logger.LogError("Failed to update room on talk: {0}", ex); } return(BadRequest("Couldn't update talk.")); }
public async Task <IActionResult> Get(string moniker) { return(Ok(await _repo.GetRoomsAsync(moniker))); }