Example #1
0
        public async Task <IActionResult> Update(string moniker, int id, [FromBody] Room model)
        {
            try
            {
                var room = _repo.GetRoom(moniker, id);
                if (room.Id != id || string.IsNullOrWhiteSpace(model.Name))
                {
                    return(BadRequest());
                }
                room.Name = model.Name;
                await _repo.SaveChangesAsync();

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

            return(BadRequest("Failed to update Room"));
        }
        public async Task <IActionResult> Delete(string moniker, int id)
        {
            try
            {
                var room = _repo.GetRoom(moniker, id);
                _repo.Delete(room);
                await _repo.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError("Couldn't Delete Favorite Room: {0}", ex);
            }

            return(BadRequest("Failed to delete Room"));
        }