def fn_update(file_name, list_labels, title, function_):
   
    id_ =  terminal_view.get_string('Updates element \nID: ')
    table, title_list = common.make_table(file_name, list_labels)
    if check_exist(table, id_, 0):  #check if there is the ID to update
        inputs = terminal_view.get_inputs(list_labels, title)
        common.make_update(inputs, file_name, id_, function_)
        terminal_view.clear()
        return True
    else:
        terminal_view.print_error_message('No such ID')
        return False
def run():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """


    title = "Store menu"
    list_options = ("Show", "Add", "Remove", "Update")
    exit_message = "Back do main menu"
    file_name = 'model/store/games.csv'
    title_labels = ('ID', 'Name', 'Studio', 'Elements', 'Sales')
    list_labels = ('Name:', 'Studio:', 'Elements:', 'Sales:')


    choice = None
    terminal_view.clear()
    while choice != "0":
        choice = terminal_view.get_choice("Store menu", list_options, exit_message)
        if choice == "1":
            terminal_view.clear()
            common.show_table(file_name, title_labels)
        elif choice == "2":
            terminal_view.clear()
            title = "Create record in store"
            common.show_table(file_name, title_labels)
            common.fn_add(file_name, list_labels, title, store.add)
            common.show_table(file_name, title_labels)
        elif choice == "3":
            terminal_view.clear()
            common.show_table(file_name, title_labels)
            common.remove_record_from_file(terminal_view.get_string("ID: "), store.remove, file_name, title_labels)
            common.show_table(file_name, title_labels)
        elif choice == "4":
            terminal_view.clear()
            common.show_table(file_name, title_labels)
            if common.fn_update(file_name, list_labels, 'Update', store.update):
                common.show_table(file_name, title_labels)
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    """
    Starts this module and displays its menu.
     * User can access default special features from here.
     * User can go back to main menu from here.

    Returns:
        None
    """

    title = "Inventory Menu"
    list_options = ('List', "Add", "Remove", "Update")
    exit_message = "Back do main menu"
    file_name = 'model/inventory/inventory.csv'
    title_labels = ('ID', 'Platform', 'Producer', 'Year', 'Elements')
    list_labels = ('Platform:', 'Producer:', 'Year:', 'Elements:')

    choice = None
    terminal_view.clear()
    while choice != '0':
        choice = terminal_view.get_choice("Inventory Menu", list_options,
                                          exit_message)
        if choice == '1':
            common.show_table(file_name, title_labels)
        elif choice == '2':
            title = "Create record in inventory"
            common.fn_add(file_name, list_labels, title, inventory.add)
            common.show_table(file_name, title_labels)
        elif choice == '3':
            common.show_table(file_name, title_labels)
            common.remove_record_from_file(terminal_view.get_string("ID: "),
                                           inventory.remove, file_name,
                                           title_labels)
        elif choice == '4':
            common.show_table(file_name, title_labels)
            if common.fn_update(file_name, list_labels, 'Update',
                                inventory.update):
                common.show_table(file_name, title_labels)
        else:
            terminal_view.print_error_message("There is no such choice.")