class LearningObjectsController < ApplicationController before_action :set_learning_object, only: [:show, :edit, :update, :destroy] # GET /learning_objects # GET /learning_objects.json def index @learning_objects = repository.for(:learning_object).all end # GET /learning_objects/1 # GET /learning_objects/1.json def show @object = repository.for(:learning_object).get_by_dspaceid params[:id] unless @object.nil? @like_counts = repository.for(:edge).get_in_edges_count "Likes", @object.first["@rid"] end end # GET /learning_objects/new def new @learning_object = repository.for(:learning_object).new end # GET /learning_objects/1/edit def edit end # POST /learning_objects # POST /learning_objects.json def create @learning_object = repository.for(:learning_object).new(learning_object_params) respond_to do |format| if @learning_object.save format.html { redirect_to @learning_object, notice: 'Learning object was successfully created.' } format.json { render :show, status: :created, location: @learning_object } else format.html { render :new } format.json { render json: @learning_object.errors, status: :unprocessable_entity } end end end # PATCH/PUT /learning_objects/1 # PATCH/PUT /learning_objects/1.json def update respond_to do |format| if @learning_object.update(learning_object_params) format.html { redirect_to @learning_object, notice: 'Learning object was successfully updated.' } format.json { render :show, status: :ok, location: @learning_object } else format.html { render :edit } format.json { render json: @learning_object.errors, status: :unprocessable_entity } end end end # DELETE /learning_objects/1 # DELETE /learning_objects/1.json def destroy @learning_object.destroy respond_to do |format| format.html { redirect_to learning_objects_url, notice: 'Learning object was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_learning_object @learning_object = repository.for(:learning_object).find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def learning_object_params params[:learning_object] end end