-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_employee_presenter.rb
112 lines (112 loc) · 2.57 KB
/
add_employee_presenter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# frozen_string_literal: true
#
# require_relative 'hourly/add_employee'
# require_relative 'salaried/add_employee'
# require_relative 'add_commissioned_employee'
#
# # Business Logic Which Adds an Employee Presenter
# class AddEmployeePresenter
# attr_reader :emp_id, :name, :address, :hourly, :hourly_rate, :has_salary, :salary,
# :has_commission, :commission_salary, :commission
# def initialize(view, container, database)
# @view = view
# @container = container
# @database = database
# end
#
# def update_view
# @view.submit_enabled = all_information_is_collected
# end
#
# def all_information_is_collected
# result = true
# result &&= emp_id && emp_id > 0
# result &&= name.present?
# result &&= address.present?
# if hourly
# result &&= hourly_rate.present? && hourly_rate.positive?
# elsif has_salary
# result &&= salary.present? && salary.positive?
# elsif has_commission
# result &&= commission_salary.present? && commission_salary.positive? && commission.present? && commission.positive?
# else
# result = false
# end
#
# result
# end
#
# def create_transaction
# if hourly
# AddEmployee.new(emp_id, name, address, hourly_rate, @database)
# elsif has_salary
# AddEmployee.new(emp_id, name, address, salary, @database)
# elsif has_commission
# AddEmployee.new(emp_id, name, address, commission_salary, commission, @database)
# end
# end
#
# def add_employee
# @container.transactions << create_transaction
# end
#
# def emp_id=(emp_id)
# @emp_id = emp_id
# update_view
# @emp_id
# end
#
# def name=(name)
# @name = name
# update_view
# @name
# end
#
# def address=(address)
# @address = address
# update_view
# @address
# end
#
# def hourly=(hourly)
# @hourly = hourly
# update_view
# @hourly
# end
#
# def hourly_rate=(hourly_rate)
# @hourly_rate = hourly_rate
# update_view
# @hourly_rate
# end
#
# def has_salary=(has_salary)
# @has_salary = has_salary
# update_view
# @has_salary
# end
#
# def salary=(salary)
# @salary = salary
# update_view
# @salary
# end
#
# def has_commission=(has_commission)
# @has_commission = has_commission
# update_view
# @has_commission
# end
#
# def commission_salary=(commission_salary)
# @commission_salary = commission_salary
# update_view
# @commission_salary
# end
#
# def commission=(commission)
# @commission = commission
# update_view
# @commission
# end
# end