diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index de89c1e4d1835e58ca4c18250d9857852471167c..4fc193f350822d133dc66158a23b821e0024ca96 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -4,7 +4,7 @@ class LearningObjectsController < ApplicationController # GET /learning_objects # GET /learning_objects.json def index - @learning_objects = repository.for(:learning_object).all + @learning_objects = learning_object_repository.all end # GET /learning_objects/1 @@ -17,7 +17,7 @@ class LearningObjectsController < ApplicationController # GET /learning_objects/new def new - @learning_object = repository.for(:learning_object).new + @learning_object = LearningObject.new end # GET /learning_objects/1/edit @@ -27,15 +27,13 @@ class LearningObjectsController < ApplicationController # POST /learning_objects # POST /learning_objects.json def create - @learning_object = repository.for(:learning_object).new(learning_object_params) + @learning_object = LearningObject.new(learning_object_params) respond_to do |format| - if @learning_object.save + if learning_object_repository.save @learning_object 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 @@ -44,12 +42,10 @@ class LearningObjectsController < ApplicationController # PATCH/PUT /learning_objects/1.json def update respond_to do |format| - if @learning_object.update(learning_object_params) + if learning_object_repository.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 @@ -57,17 +53,22 @@ class LearningObjectsController < ApplicationController # DELETE /learning_objects/1 # DELETE /learning_objects/1.json def destroy - @learning_object.destroy + learning_object_repository.destroy @learning_object + 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 + + def learning_object_repository + repository.for(:learning_object) + end + # Use callbacks to share common setup or constraints between actions. def set_learning_object - @learning_object = repository.for(:learning_object).get_by_dspaceid params[:id] + @learning_object = learning_object_repository.get_by_dspaceid params[:id] end # Never trust parameters from the scary internet, only allow the white list through.