Ejemplo n.º 1
0
        public IActionResult Get()
        {
            var response = new ListResponse <ShapesDTO>();

            try
            {
                var result = _shapesLogic.GetAllShapes();
                //throw new Exception();


                if (result == null)
                {
                    response.Messages = ResponseMessages.NotFound();
                    return(NotFound(response));
                }
                response.Messages = ResponseMessages.Success();
                response.Model    = result.ToList();
                return(Ok(response));
            }
            catch (Exception exception)
            {
                response.Messages = ResponseMessages.InternalServerError(exception.ToString());
                return(StatusCode(500, response));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Get(int id)
        {
            var response = new EmployeeResponse()
            {
                Result = null
            };

            try
            {
                var result = await _employeeService.GetEmployeesById(id);

                if (result == null)
                {
                    response.Messages = ResponseMessages.NotFound();
                    return(NotFound(response));
                }
                response.Messages = ResponseMessages.Success();
                response.Result   = result;
                return(Ok(response));
            }
            catch (Exception exception)
            {
                response.Messages = ResponseMessages.InternalServerError(exception.ToString());
                return(StatusCode(500, response));
            }
        }
Ejemplo n.º 3
0
        public IActionResult Get(int id)
        {
            var response = new SingleResponse <ShapesDTO>();

            try
            {
                var result = _shapesLogic.GetShapeById(id);
                if (result == null)
                {
                    response.Messages = ResponseMessages.NotFound();
                    return(NotFound(response));
                }
                response.Messages = ResponseMessages.Success();
                response.Model    = result;
                return(Ok(response));
            }
            catch (Exception exception)
            {
                response.Messages = ResponseMessages.InternalServerError(exception.ToString());
                return(StatusCode(500, response));
            }
        }