Exemplo n.º 1
0
        public void DeletePark(ParqueCampismo park)
        {
            if (park == null)
            {
                throw new ArgumentException("The ParqueCampismo cannot be null to be deleted");
            }

            EnsureContext();

            using (IDbCommand command = context.createCommand()) {
                command.CommandText = DeleteParkFindHóspedesCommandText;
                command.CommandType = DeleteParkFindHóspedesCommandType;

                SqlParameter nomeParq = new SqlParameter("@nomeParque", park.nome);

                command.Parameters.Add(nomeParq);

                List <Hóspede> hospedes = new List <Hóspede>();
                IDataReader    reader   = command.ExecuteReader();

                while (reader.Read())
                {
                    Hóspede h = new Hóspede();
                    h.NIF = reader.GetInt32(0);
                    hospedes.Add(h);
                }

                HóspedeMapper hospedeMapper = new HóspedeMapper(context);
                hospedes.ForEach(h => {
                    hospedeMapper.Delete(h);
                });

                reader.Close();
                command.Parameters.Clear();

                command.CommandText = DeleteParkCommandText;
                command.CommandType = DeleteParkCommandType;
                SqlParameter nome = new SqlParameter("@nome", park.nome);

                command.Parameters.Add(nome);

                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 2
0
        public Tuple <int, int> FindFacturas(Hóspede hóspede, DateTime dataInicio, DateTime dataFim, ParqueCampismo parqueCampismo)
        {
            if (hóspede == null)
            {
                throw new ArgumentException("The hóspede cannot be null");
            }

            LinkedList <Factura> facturas = new LinkedList <Factura>();

            using (IDbCommand command = context.createCommand()) {
                command.CommandText = FindFacturaCommandText;
                command.CommandType = FindFacturaCommandType;

                FillParametersFindFactura(command, hóspede, dataInicio, dataFim, parqueCampismo.nome);

                IDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Factura f = new Factura();
                    f.id         = reader.GetInt32(1);
                    f.preçoTotal = reader.GetInt32(0);
                    facturas.AddLast(f);
                }
            }
            return(CalcularDespesasHospede(facturas, hóspede.NIF));
        }