Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1133 | Rev 1138 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1133 Rev 1134
Línea 152... Línea 152...
152
 
152
 
153
                if ($currentCompany) {
153
                if ($currentCompany) {
154
                    $behavior->company_id = $currentCompany->id;
154
                    $behavior->company_id = $currentCompany->id;
Línea 155... Línea -...
155
                }
-
 
156
 
155
                }
Línea 157... Línea -...
157
 
-
 
158
                $behaviorMapper = BehaviorsMapper::getInstance($this->adapter);
-
 
159
 
-
 
160
                $result = $behaviorMapper->insert($behavior);
156
 
Línea 161... Línea 157...
161
 
157
                $behaviorMapper = BehaviorsMapper::getInstance($this->adapter);
162
                if ($result) {
-
 
163
                    $this->logger->info('Se agrego la conducta observable ' . $behavior->description, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
-
 
164
 
-
 
165
                    $data = [
-
 
-
 
158
 
166
                        'success' => true,
159
                $recordExists = $behaviorMapper->fetchOneByDescription($dataPost['description'], $currentCompany ? $currentCompany->id : null);
167
                        'data' => $behavior
160
 
168
                    ];
161
                if ($recordExists) {
169
                } else {
162
                    
-
 
163
                    $data = [
-
 
164
                        'success' => false,
-
 
165
                        'message' => 'El registro ya existe'
-
 
166
                    ];
-
 
167
                    
-
 
168
                } else {
-
 
169
 
-
 
170
                    $result = $behaviorMapper->insert($behavior);
-
 
171
 
-
 
172
                    if ($result) {
-
 
173
                        
-
 
174
                        $this->logger->info('Se agrego la conducta observable ' . $behavior->description, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
-
 
175
 
-
 
176
                        $recordExists = $behaviorMapper->fetchOneByDescription($dataPost['description'], $currentCompany ? $currentCompany->id : null);
-
 
177
                       
-
 
178
                        if ($recordExists) {
-
 
179
                            $data = [
-
 
180
                                'success' => true,
-
 
181
                                'uuid' => $recordExists->uuid
-
 
182
                            ];
-
 
183
                        }
-
 
184
                        
-
 
185
                    } else {
-
 
186
                        $data = [
170
                    $data = [
187
                            'success' => false,
Línea 171... Línea 188...
171
                        'success' => false,
188
                            'data' => $behaviorMapper->getError()
172
                        'data' => $behaviorMapper->getError()
189
                        ];
173
                    ];
190
                    }