private HardwareDeSalaViewModel Cast(HardwareDeSalaModel item)
        {
            HardwareDeSalaViewModel h = new HardwareDeSalaViewModel();

            h.Id             = item.Id;
            h.MAC            = item.MAC;
            h.Ip             = item.Ip;
            h.SalaId         = _salaService.GetById(item.SalaId);
            h.TipoHardwareId = _tipoHardwareService.GetById(item.TipoHardwareId);

            return(h);
        }
        public ActionResult Get(int id)
        {
            try
            {
                var tipo = _service.GetById(id);
                if (tipo == null)
                {
                    return(NotFound("Tipo de Hardware não encontrado na base de dados."));
                }

                return(Ok(tipo));
            }
            catch (ServiceException e)
            {
                return(StatusCode(500, e.Message));
            }
        }
        private SalaViewModel GetSalaViewModel(int id)
        {
            var sala = _salaService.GetById(id);
            var hardwaresViewModel = new List <HardwareDeSalaViewModel>();

            foreach (var item in _hardwareDeSalaService.GetByIdSala(id))
            {
                hardwaresViewModel.Add(new HardwareDeSalaViewModel {
                    Id = item.Id, MAC = item.MAC, TipoHardwareId = _tipoHardwareService.GetById(item.TipoHardwareId)
                });
            }

            return(new SalaViewModel
            {
                Sala = sala,
                HardwaresSala = hardwaresViewModel,
                BlocoSala = _blocoService.GetById(sala.BlocoId)
            });
        }