예제 #1
0
파일: Program.cs 프로젝트: Anayamd/DiegoLib
    public static void Main(string[] args)
    {
        string[] accionesAdmin = { "alta", "baja", "cambio", "ver", "recetas", "ver recetas", "salir", "1", "2", "3", "4", "5" };
        string[] accionesUsuario = { "ver", "recetas", "ver recetas", "1", "2" };
        string[] finRecopilarInfo = { "exit", "quit", "bye", "listo", "ya", "nos vemos", "chao", "salir" };

        Libro lib = new Libro();

        string accion;
        string user;
        string password = "******";
        string input;

        do {
            user = "******";
            Console.Clear();
            input = Basics.getString("> LOGIN\nDeseas ser admin o usuario o salir: ").ToLower();
            if (finRecopilarInfo.Contains(input)) {
                break;
            }

            if (!input.Contains('u')) {
                if (Basics.getString("Contraseña: ") == password) {
                    user = "******";
                }
            }

            if (user == "user") {
                do
                {
                    userMenu ();
                    do {
                        accion = Basics.getString("\nAcción a realizar: ").ToLower();
                    } while ( !finRecopilarInfo.Contains(accion) && !accionesUsuario.Contains(accion) );

                    if (accion == "2" || finRecopilarInfo.Contains(accion)) {
                        break;
                    }

                    lib.imprimeNombres();
                }
                while (!finRecopilarInfo.Contains(accion));
            }

            if (user == "admin") {
                do
                {
                    adminMenu ();
                    do {
                        accion = Basics.getString("\nAcción a realizar: ").ToLower();
                    } while ( !finRecopilarInfo.Contains(accion) && !accionesAdmin.Contains(accion) );

                    if (accion == "5" || finRecopilarInfo.Contains(accion)) {
                        break;
                    }

                    if (accion == "1" || accion == "alta") {
                        lib.crearReceta();
                    }

                    if (accion == "2" || accion == "baja")
                    {
                        lib.eliminaReceta();
                    }

                    if (accion == "3" || accion == "cambio")
                    {
                        lib.cambiosEnReceta();
                    }

                    if ( accion == "4" || accion.Contains("ver") || accion.Contains("receta")) {
                        lib.imprimeNombres();
                    }
                }
                while (!finRecopilarInfo.Contains(accion));
            }

        } while (true);
    }