X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=app%2Fmodels%2Fcustomer.rb;h=5509439cb8f1c87d5f17dfbcfc3eea5e7b31dcdc;hb=233a6b122bc4aed44a0babee0797d2dba6da5b06;hp=e56eafe0151a16c8443ff8a9b86e9983d77a0618;hpb=9218748c58d552432e7bd4a34383589eb17ac331;p=cs356-p2-videostore.git diff --git a/app/models/customer.rb b/app/models/customer.rb index e56eafe..5509439 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,6 +1,5 @@ class Customer < ActiveRecord::Base has_many :coitems - has_many :bitems has_many :merchandise_purchases has_many :rentable_purchases @@ -33,6 +32,32 @@ class Customer < ActiveRecord::Base return game_count end + def overdue_videos + coitems = Coitem.find_all_by_customer_id(id) + overdue_video_count = 0 + + for item in coitems + if item.rentable.class == Video and item.overdue? + overdue_video_count += 1 + end + end + + return overdue_video_count + end + + def overdue_games + coitems = Coitem.find_all_by_customer_id(id) + overdue_game_count = 0 + + for item in coitems + if item.rentable.class == Game and item.overdue? + overdue_game_count += 1 + end + end + + return overdue_game_count + end + protected def validate