示例#1
0
        public async Task <IActionResult> UpdateRoom(string moniker, int id, [FromBody] TalkViewModel model)
        {
            try
            {
                var talk = _repo.GetTalk(id);
                var room = _repo.GetRooms(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(talk));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to update room on talk: {0}", ex);
            }

            return(BadRequest("Couldn't update talk."));
        }
 public IActionResult Get(string moniker)
 {
     return(Ok(_repo.GetRooms(moniker)));
 }