@@ -5,8 +5,8 @@ app.controller('StudentCtrl', ['$scope','StudentService', function ($scope,Stude
55 pageNumber : 1 ,
66 pageSize : 5 ,
77 sort : null
8- } ;
9-
8+ } ;
9+
1010 StudentService . getStudents ( paginationOptions . pageNumber ,
1111 paginationOptions . pageSize ) . success ( function ( data ) {
1212 $scope . gridOptions . data = data . content ;
@@ -54,145 +54,3 @@ app.service('StudentService',['$http', function ($http) {
5454 } ;
5555
5656} ] ) ;
57-
58- app . controller ( 'EmployeeCRUDCtrl' , [ '$scope' , 'EmployeeCRUDService' , function ( $scope , EmployeeCRUDService ) {
59-
60- $scope . updateEmployee = function ( ) {
61- EmployeeCRUDService . updateEmployee ( $scope . employee . id , $scope . employee . name , $scope . employee . age )
62- . then ( function success ( response ) {
63- $scope . message = 'Employee data updated!' ;
64- $scope . errorMessage = '' ;
65- } ,
66- function error ( response ) {
67- $scope . errorMessage = 'Error updating Employee!' ;
68- $scope . message = '' ;
69- } ) ;
70- }
71-
72- $scope . getEmployee = function ( ) {
73- var id = $scope . employee . id ;
74- EmployeeCRUDService . getEmployee ( $scope . employee . id )
75- . then ( function success ( response ) {
76- $scope . employee = response . data ;
77- $scope . employee . id = id ;
78- $scope . message = '' ;
79- $scope . errorMessage = '' ;
80- } ,
81- function error ( response ) {
82- $scope . message = '' ;
83- if ( response . status === 404 ) {
84- $scope . errorMessage = 'Employee not found!' ;
85- }
86- else {
87- $scope . errorMessage = "Error getting Employee!" ;
88- }
89- } ) ;
90- }
91-
92- $scope . addEmployee = function ( ) {
93- if ( $scope . employee != null && $scope . employee . id ) {
94- EmployeeCRUDService . addEmployee ( $scope . employee . id , $scope . employee . name , $scope . employee . age )
95- . then ( function success ( response ) {
96- $scope . message = 'Employee added!' ;
97- $scope . errorMessage = '' ;
98- } ,
99- function error ( response ) {
100- $scope . errorMessage = 'Error adding Employee!' ;
101- $scope . message = '' ;
102- } ) ;
103- }
104- else {
105- $scope . errorMessage = 'Please enter an id!' ;
106- $scope . message = '' ;
107- }
108- }
109-
110- $scope . deleteEmployee = function ( ) {
111- EmployeeCRUDService . deleteEmployee ( $scope . employee . id )
112- . then ( function success ( response ) {
113- $scope . message = 'Employee deleted!' ;
114- $scope . employee = null ;
115- $scope . errorMessage = '' ;
116- } ,
117- function error ( response ) {
118- $scope . errorMessage = 'Error deleting Employee!' ;
119- $scope . message = '' ;
120- } )
121- }
122-
123- $scope . getAllEmployees = function ( ) {
124- EmployeeCRUDService . getAllEmployees ( )
125- . then ( function success ( response ) {
126- $scope . employees = response . data . _embedded . employee ;
127- $scope . message = '' ;
128- $scope . errorMessage = '' ;
129- } ,
130- function error ( response ) {
131- $scope . message = '' ;
132- $scope . errorMessage = 'Error getting Employees!' ;
133- } ) ;
134- }
135-
136- $scope . getEmployeesByName = function ( ) {
137- EmployeeCRUDService . getEmployeesByName ( $scope . name )
138- . then ( function success ( response ) {
139- $scope . employees = response . data . _embedded . employee ;
140- $scope . message = '' ;
141- $scope . errorMessage = '' ;
142- } ,
143- function error ( response ) {
144- $scope . message = '' ;
145- $scope . errorMessage = 'Error getting Employees!' ;
146- } ) ;
147- }
148-
149- } ] ) ;
150-
151- app . service ( 'EmployeeCRUDService' , [ '$http' , function ( $http ) {
152-
153- this . getEmployee = function getEmployee ( employeeId ) {
154- return $http ( {
155- method : 'GET' ,
156- url :'employees/' + employeeId
157- } ) ;
158- }
159-
160- this . addEmployee = function addEmployee ( id , name , age , gender ) {
161- return $http ( {
162- method : 'POST' ,
163- url :'employees' ,
164- data : { id :id , name :name , age :age }
165- } ) ;
166- }
167-
168- this . deleteEmployee = function deleteEmployee ( id ) {
169- return $http ( {
170- method : 'DELETE' ,
171- url : 'employees/' + id
172- } )
173- }
174-
175- this . updateEmployee = function updateEmployee ( id , name , age ) {
176- return $http ( {
177- method : 'PATCH' ,
178- url : 'employees/' + id ,
179- data : { name :name , age :age }
180- } )
181- }
182-
183- this . getAllEmployees = function getAllEmployees ( ) {
184- return $http ( {
185- method : 'GET' ,
186- url :'employees'
187- } ) ;
188- }
189-
190- this . getEmployeesByName = function getEmployeesByName ( name ) {
191- return $http ( {
192- method : 'GET' ,
193- url :'employees/search/findByName' ,
194- params :{ name :name }
195- } ) ;
196- }
197-
198- } ] ) ;
0 commit comments