public IHttpActionResult ConsultarNaoRestricoes(int id)
        {
            EntidadesResponse <CategoriaTO> response = new EntidadesResponse <CategoriaTO>();

            try
            {
                List <CategoriaEquipamento> categorias = Local.ConsultarNaoRestricoes(id);

                foreach (CategoriaEquipamento ce in categorias)
                {
                    CategoriaTO cTO = new CategoriaTO();
                    cTO.Id   = ce.Id;
                    cTO.Nome = ce.Nome;
                    cTO.ComentarioReserva = ce.ComentarioReserva;

                    response.Elementos.Add(cTO);
                }
            }
            catch (EntidadesException eex)
            {
                response.Status   = (int)eex.Codigo;
                response.Detalhes = eex.Message;
            }
            catch (Exception ex)
            {
                response.Status   = -1;
                response.Detalhes = ex.Message;
            }
            return(Ok(response));
        }
Exemple #2
0
        public IHttpActionResult Get([FromUri] string data, [FromUri] string horario, [FromUri] string turno)
        {
            EntidadesResponse <CategoriaTO> response = new EntidadesResponse <CategoriaTO>();

            try
            {
                DateTime d = DateTime.ParseExact(data, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                List <CategoriaEquipamento> categorias = CategoriaEquipamento.ConsultarCategoriasDisponiveis(d, horario, turno);

                foreach (CategoriaEquipamento ce in categorias)
                {
                    CategoriaTO cTO = new CategoriaTO();
                    cTO.Id   = ce.Id;
                    cTO.Nome = ce.Nome;
                    cTO.ComentarioReserva = ce.ComentarioReserva;

                    response.Elementos.Add(cTO);
                }
            }
            catch (EntidadesException eex)
            {
                response.Status   = (int)eex.Codigo;
                response.Detalhes = eex.Message;
            }
            catch (Exception ex)
            {
                response.Status   = -1;
                response.Detalhes = ex.Message;
            }
            return(Ok(response));
        }
Exemple #3
0
        public IHttpActionResult Put(int id, [FromBody] CategoriaTO categoria)
        {
            CategoriaResponse cResponse = new CategoriaResponse();

            try
            {
                Categoria.Atualizar(id, categoria.Nome);
            }
            catch (Exception ex)
            {
                cResponse.Status    = -1;
                cResponse.Descricao = ex.Message;
            }

            return(Ok(cResponse));
        }
Exemple #4
0
        public IHttpActionResult Post([FromBody] CategoriaTO cTO)
        {
            CategoriaResponse cResponse = new CategoriaResponse();

            cResponse.Categorias = new List <CategoriaTO>();
            try
            {
                Categoria.Inserir(cTO.Nome);
            }
            catch (Exception ex)
            {
                cResponse.Status    = -1;
                cResponse.Descricao = ex.Message;
            }
            return(Ok(cResponse));
        }
Exemple #5
0
        public IHttpActionResult Remover([FromBody] CategoriaTO categoria)
        {
            BaseResponse response = new BaseResponse();

            try
            {
                CategoriaEquipamento.Remover(categoria.Id);
            }
            catch (EntidadesException eex)
            {
                response.Status   = (int)eex.Codigo;
                response.Detalhes = eex.Message;
            }
            catch (Exception ex)
            {
                response.Status   = -1;
                response.Detalhes = ex.Message;
            }
            return(Ok(response));
        }
Exemple #6
0
        public IHttpActionResult Get(int id)
        {
            CategoriaResponse cResponse = new CategoriaResponse();

            cResponse.Categorias = new List <CategoriaTO>();
            try
            {
                Categoria categoria = Categoria.Consultar(id);

                CategoriaTO cTO = new CategoriaTO();
                cTO.Id   = categoria.Id;
                cTO.Nome = categoria.Nome;
                cResponse.Categorias.Add(cTO);
            }
            catch (Exception ex)
            {
                cResponse.Status    = -1;
                cResponse.Descricao = ex.Message;
            }
            return(Ok(cResponse));
        }
Exemple #7
0
        public IHttpActionResult Post([FromBody] CategoriaTO categoria)
        {
            EntidadeResponse <CategoriaTO> response = new EntidadeResponse <CategoriaTO>();

            response.Elemento = categoria;

            try
            {
                response.Elemento.Id = CategoriaEquipamento.Cadastrar(categoria.Nome, categoria.ComentarioReserva);
            }
            catch (EntidadesException eex)
            {
                response.Status   = (int)eex.Codigo;
                response.Detalhes = eex.Message;
            }
            catch (Exception ex)
            {
                response.Status   = -1;
                response.Detalhes = ex.Message;
            }
            return(Ok(response));
        }
Exemple #8
0
        public IHttpActionResult Get()
        {
            CategoriaResponse cResponse = new CategoriaResponse();

            cResponse.Categorias = new List <CategoriaTO>();
            try
            {
                List <Categoria> categorias = Categoria.Listar();
                foreach (Categoria c in categorias)
                {
                    CategoriaTO cTO = new CategoriaTO();
                    cTO.Id   = c.Id;
                    cTO.Nome = c.Nome;
                    cResponse.Categorias.Add(cTO);
                }
            }
            catch (Exception ex)
            {
                cResponse.Status    = -1;
                cResponse.Descricao = ex.Message;
            }
            return(Ok(cResponse));
        }