コード例 #1
0
        // GET: api/Cliente/5
        public GenericResponse <ClienteDto> Get(int id)
        {
            GenericResponse <ClienteDto> response = new GenericResponse <ClienteDto>();

            try
            {
                response.Data = servicio.BuscarPorId(id);
                if (response.Data == null)
                {
                    throw new CustomResponseException("No se encontró al cliente", 404);
                }
                response.Error   = false;
                response.Mensaje = "Ok";
                response.Codigo  = 200;
            }
            catch (CustomResponseException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new CustomResponseException(ex.Message, 500);
            }


            return(response);
        }