class NotificationSettingsController < ApplicationController

  before_filter :require_login

  # To update notification setting of user.(i.e. manage notifications in user settings)
  def create_or_update
    respond_to do |format|
      @user_notification_type = current_user.notification_settings.find_or_initialize_by(notification_type: params[:notification_setting][:notification_type])
      @user_notification_type.enabled = params[:notification_setting][:enabled]
      if @user_notification_type.save
        @message = 'Notification Type Updated successfully.'
        format.js
      else
        @message = 'Notification Type Not Updated.'
        format.js
      end
    end
  end

end
