Ejemplo n.º 1
0
        public void SetPreferencesUtilizador(int id, Collection <Int32> gostos, Collection <Int32> naogostos)
        {
            Connection c = new Connection();

            Utilizadores = new UtilizadorDAO(c);
            Ingredientes = new IngredienteDAO(c);

            if (!CheckAmbiguidade(gostos, naogostos))
            {
                throw new System.InvalidOperationException("You have incompatible preferences! Plese try again.");
            }

            Collection <Ingrediente> gostosI    = new Collection <Ingrediente>();
            Collection <Ingrediente> naogostosI = new Collection <Ingrediente>();

            foreach (int i in gostos)
            {
                gostosI.Add(Ingredientes.FindById(i));
            }

            foreach (int j in naogostos)
            {
                naogostosI.Add(Ingredientes.FindById(j));
            }

            Utilizadores.AtualizaPreferencias(id, gostosI, naogostosI);
        }