Exemplo n.º 1
0
    def update(self, id, request_update_dict):
        connection = MsqlConnection()
        sentence_searh = "SELECT * FROM request_update WHERE ID = " + str(id)
        row = connection.get_one(sentence_searh)
        if row:
            sentence_search2 = "SELECT * FROM support_department WHERE id='" + request_update_dict[
                "id_department_support"] + "'"
            row2 = connection.get_all(sentence_search2)
            if row2:
                sentence_search3 = "SELECT * FROM request WHERE id='" + request_update_dict[
                    "id_request"] + "'"
                row3 = connection.get_all(sentence_search3)
                if row3:
                    x = datetime.datetime.now()
                    current_date = str(x.year) + "-" + str(
                        x.month) + "-" + str(x.day)
                    sentence = "UPDATE request_update set id_department_support = '" + request_update_dict[
                        "id_department_support"] + "',  description = '" + request_update_dict[
                            "description"] + "',  status = '" + request_update_dict[
                                "status"] + "',  date = '" + str(
                                    current_date
                                ) + "',  id_request = '" + request_update_dict[
                                    "id_request"] + "' WHERE ID = '" + str(
                                        id) + "'"
                    connection.execute(sentence)
                    connection.commit()

                    connection.close_connection()
                    return "request_update was updated"
                else:
                    return "id request does not exist"
            else:
                return "id support deparment does not exist"
        return "This request_update does not exist"
Exemplo n.º 2
0
    def update(self, id, request_dict):
        connection = MsqlConnection()
        sentenceSearh = "SELECT * FROM request WHERE ID = " + str(id)
        row = connection.get_one(sentenceSearh)
        if row:
            sentence_search = "SELECT * FROM problem_types WHERE id='" + request_dict["id_problem_type"] + "'"
            row_2 = connection.get_all(sentence_search)
            if row_2:
                x = datetime.datetime.now()
                current_date = str(x.year) + "-" + str(x.month) + "-" + str(x.day)
                sentence = "UPDATE request set id_problemType = '" + request_dict[
                    "id_problem_type"] + "',  description = '" + request_dict["description"] + "',  creation_date = '" + \
                           request_dict["creation_date"] + "',  update_date = '" + request_dict[
                               "update_date"] + "',  date_closed_ticket = '" + request_dict[
                               "date_closed_ticket"] + "',  status = '" + request_dict[
                               "status"] + "',  solution = '" + request_dict[
                               "solution"] + "',  priority = '" + request_dict[
                               "priority"] + "',  country = '" + request_dict[
                               "country"] + "' WHERE ID = '" + str(id) + "'"
                connection.execute(sentence)
                connection.commit()

                connection.close_connection()
                return "request was updated"
            else:
                connection.close_connection()
                return "This problem type does not exist"
        else:
            connection.close_connection()
            return "This request does not exist"
Exemplo n.º 3
0
 def delete(self, id):
     connection = MsqlConnection()
     sentence_search = "SELECT * FROM departments_involved WHERE ID = " + str(id)
     row = connection.get_one(sentence_search)
     if row:
         sentence = "DELETE FROM departments_involved WHERE ID = '" + str(id) + "'"
         connection.execute(sentence)
         connection.commit()
         connection.close_connection()
         return "departments_involved was deleted"
     return "This departments_involved does not exist"
Exemplo n.º 4
0
 def delete(self, id):
     connection = MsqlConnection()
     sentenceSearh = "SELECT * FROM request WHERE ID = " + str(id)
     row = connection.get_one(sentenceSearh)
     if row:
         sentence = "DELETE FROM request WHERE ID = '" + str(id) + "'"
         connection.execute(sentence)
         connection.commit()
         connection.close_connection()
         return "request was deleted"
     return "This request does not exist"
Exemplo n.º 5
0
    def update(self, id, department_dict):
        connection = MsqlConnection()
        sentenceSearh = "SELECT * FROM department WHERE ID = " + str(id)
        row = connection.get_one(sentenceSearh)
        if row:
            sentence = "UPDATE department set department = '" + department_dict["department"] + "' WHERE ID = '" + str(id) + "'"
            connection.execute(sentence)
            connection.commit()

            connection.close_connection()
            return "Department was updated"
        return "This department does not exist"
Exemplo n.º 6
0
    def update(self, id, user_dict):
        connection = MsqlConnection()
        sentenceSearh = "SELECT * FROM users WHERE ID = " + str(id)
        row = connection.get_one(sentenceSearh)
        if row:
            sentence = "UPDATE users set first_name = '" + user_dict["first_name"] + "',  last_name = '" + user_dict["last_name"] + "', phone = '" + user_dict["phone"] + "', email = '" + user_dict["email"] + "', employee_serial = '" + user_dict["employee_serial"] + "' WHERE ID = '" + str(id) + "'"
            connection.execute(sentence)
            connection.commit()

            connection.close_connection()
            return "User was updated"
        return "This user does not exist"
Exemplo n.º 7
0
 def delete(self, id):
     connection = MsqlConnection()
     sentence_search = "SELECT * FROM employee_in_charge WHERE ID = " + str(
         id)
     row = connection.get_one(sentence_search)
     if row:
         sentence = "DELETE FROM employee_in_charge WHERE ID = '" + str(
             id) + "'"
         connection.execute(sentence)
         connection.commit()
         connection.close_connection()
         return "employee_in_charge was deleted"
     return "This employee_in_charge does not exist"
Exemplo n.º 8
0
    def update(self, id, problem_types_dict):
        connection = MsqlConnection()
        sentenceSearh = "SELECT * FROM problem_types WHERE ID = " + str(id)
        row = connection.get_one(sentenceSearh)
        if row:
            sentence = "UPDATE problem_types set name = '" + problem_types_dict[
                "name"] + "',  description = '" + problem_types_dict[
                    "description"] + "' WHERE ID = '" + str(id) + "'"
            connection.execute(sentence)
            connection.commit()

            connection.close_connection()
            return "problem_types was updated"
        return "This problem_types does not exist"
Exemplo n.º 9
0
    def update(self, id, employee_in_charge_dict):
        connection = MsqlConnection()
        sentence_search = "SELECT * FROM employee_in_charge WHERE ID = " + str(
            id)
        row = connection.get_one(sentence_search)
        if row:
            sentence = "UPDATE employee_in_charge set id_department = '" + employee_in_charge_dict[
                "id_department"] + "',  first_name = '" + employee_in_charge_dict["last_name"] + "',  phone = '" + \
                       employee_in_charge_dict["phone"] + "',  email = '" + employee_in_charge_dict[
                           "email"] + "',  employee_serial = '" + employee_in_charge_dict[
                           "employee_serial"] + "' WHERE ID = '" + str(id) + "'"
            connection.execute(sentence)
            connection.commit()

            connection.close_connection()
            return "employee_in_charge was updated"
        return "This employee_in_charge does not exist"
Exemplo n.º 10
0
    def update(self, id, department_country_support_dict):
        connection = MsqlConnection()
        sentenceSearh = "SELECT * FROM department_country_support WHERE ID = " + str(
            id)
        row = connection.get_one(sentenceSearh)
        if row:
            sentence_valid_department = "SELECT * FROM department WHERE id ='" + department_country_support_dict[
                "id_department"] + "'"
            row_valid = connection.get_all(sentence_valid_department)
            if row_valid:
                sentence = "UPDATE department_country_support set id_department = '" + department_country_support_dict[
                    "id_department"] + "',  country = '" + department_country_support_dict[
                        "country"] + "' WHERE ID = '" + str(id) + "'"
                connection.execute(sentence)
                connection.commit()

                connection.close_connection()
                return "department_country_support was updated"
            else:
                return "This department id does not exist"
        else:
            return "This department_country_support does not exist"
Exemplo n.º 11
0
 def getId(self, mail):
     connection = MsqlConnection()
     sentenceSearh = "SELECT ID FROM users WHERE EMAIL = '" + mail + "'"
     record = connection.get_one(sentenceSearh)
     return record[0]