public IHttpActionResult GetDimension([FromUri] GetDimensionRequest obj) { try { // Business layer DimensionsService core = new DimensionsService(); // Verify at least object arrives with data if (obj == null) { throw new NotEnoughAttributesException("No se ha recibido ningún parámetro"); } // Verify for parameters needed if (obj.idProduct == 0 || obj.idClient == 0 || obj.idProfile == 0 || obj.idDimension == 0) { throw new NotEnoughAttributesException("No se han recibido todos los parámetros requeridos"); } // Actions into business layer ActionResponse action = core.GetDimensionAction(obj.idProduct, obj.idClient, obj.idProfile, obj.idDimension); if (action.code == (int)CodeStatusEnum.OK) { return(ResponseOk(action.data)); } // OK else { return(ResponseError(action.code, action.message)); } // NOK } catch (NotValidDataException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (NotEnoughAttributesException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (Exception ex) { logger.Fatal(ex.Message); return(ResponseError((int)CodeStatusEnum.INTERNAL_ERROR, "Error desconocido en el sistema: " + ex.Message)); } }
public IHttpActionResult GetDimensions([FromUri] GetDimensionRequest request) { try { // Verify required parameters if (request.idProduct == 0) { throw new NotEnoughAttributesException("No se han recibido todos los parámetros requeridos"); } // Business layer DimensionsService core = new DimensionsService(); // Actions into business layer ActionResponse action = core.GetDimensionsByProductAction(request.idProduct); if (action.code == (int)CodeStatusEnum.OK) // Success { return(ResponseOk(action.data)); } else // Error { return(ResponseError(action.code, action.message)); } } catch (NotValidDataException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (NotEnoughAttributesException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (Exception ex) { logger.Fatal(ex.Message); return(ResponseError((int)CodeStatusEnum.INTERNAL_ERROR, "Error desconocido en el sistema: " + ex.Message)); } }