From c1189de6b92cb7a2e15c4451a8c4bbed827b27df Mon Sep 17 00:00:00 2001
From: Anton Bagliy <taccessviolation@gmail.com>
Date: Sat, 10 Nov 2018 17:25:46 +0300
Subject: [PATCH] FIX: adding teachers by full name, job title, job status and
 dep id only closes #328

---
 .../application/classes/Controller/Api/V0/Teacher.php      | 7 +++++--
 ~dev_rating/application/classes/Model/Teacher.php          | 3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/~dev_rating/application/classes/Controller/Api/V0/Teacher.php b/~dev_rating/application/classes/Controller/Api/V0/Teacher.php
index 6c49cc915..17602abea 100644
--- a/~dev_rating/application/classes/Controller/Api/V0/Teacher.php
+++ b/~dev_rating/application/classes/Controller/Api/V0/Teacher.php
@@ -76,8 +76,11 @@ class Controller_Api_V0_Teacher extends Controller_Handler_Api {
             $teacher = $teacher->inila($teacherData->inila);
         }
         $teacher = $teacher->create();
-
-        return (int)$teacher->ID;
+        if (isset($teacher->ActivationCode)) {
+            return [(int)$teacher->ID, $teacher->ActivationCode];
+        } else {
+            return (int)$teacher->ID;
+        }
     }
 
     private function updateTeacher($teacherData) {
diff --git a/~dev_rating/application/classes/Model/Teacher.php b/~dev_rating/application/classes/Model/Teacher.php
index 492bc123f..efeb763a1 100644
--- a/~dev_rating/application/classes/Model/Teacher.php
+++ b/~dev_rating/application/classes/Model/Teacher.php
@@ -71,6 +71,9 @@ class Model_Teacher extends Model_Container
                 ->parameters($this->data)
                 ->execute()->get('ID');
         } else {
+            if (!isset($this->data["DepID"])) {
+                $this->DepID = $this->data['FacultyID'];
+            }
             $sql = 'SELECT * FROM Teacher_Create(LastName, FirstName, SecondName, JobPositionID, DepID, 
                                                 ActivationCode) AS "ID"';
 
-- 
GitLab