Beispiel #1
0
        private static void UpdateTenda()
        {
            Tenda tenda = new Tenda();

            Console.Write("Nome do parque: ");
            tenda.nomeParque = Console.ReadLine();

            Console.Write("Localização: ");
            tenda.localização = Console.ReadLine();

            Console.Write("Descrição: ");
            tenda.descrição = Console.ReadLine();

            Console.Write("Preço Base: ");
            tenda.preçoBase = int.Parse(Console.ReadLine());

            Console.Write("Número Máximo de Pessoas: ");
            tenda.númeroMáximoPessoas = int.Parse(Console.ReadLine());

            Console.Write("Área: ");
            tenda.área = int.Parse(Console.ReadLine());

            using (Context context = new Context(connectionString)) {
                TendaMapper tendaMapper = new TendaMapper(context);
                tendaMapper.Update(tenda);
            }
        }
Beispiel #2
0
        protected override void DeleteParameters(IDbCommand command, Tenda e)
        {
            SqlParameter location = new SqlParameter("@localização", e.localização);
            SqlParameter parkName = new SqlParameter("@nomeParque", e.nomeParque);

            command.Parameters.Add(location);
            command.Parameters.Add(parkName);
        }
Beispiel #3
0
        public TendaProxy(Tenda c, IContext ctx) : base()
        {
            context = ctx;

            base.Tipo       = c.Tipo;
            base.Area       = c.Area;
            base.Alojamento = null;
        }
Beispiel #4
0
        protected override Tenda UpdateEntityID(IDbCommand command, Tenda e)
        {
            var parkName = command.Parameters["@nomeParque"] as SqlParameter;
            var location = command.Parameters["@localização"] as SqlParameter;

            e.nomeParque  = parkName.Value.ToString();
            e.localização = location.Value.ToString();
            return(e);
        }
Beispiel #5
0
        private static void CreateEstadaInTime()
        {
            Hóspede responsável     = new Hóspede();
            Hóspede hóspede         = new Hóspede();
            Estada  estada          = new Estada();
            Extra   extraPessoal    = new Extra();
            Extra   extraAlojamento = new Extra();

            Console.Write("NIF Hóspede Responsável: ");
            responsável.NIF = int.Parse(Console.ReadLine());

            Console.Write("NIF Hóspede Acompanhante: ");
            hóspede.NIF = int.Parse(Console.ReadLine());

            Console.Write("Data Inicial da Estada(YYYY-MM-DD HH:MM:SS): ");
            estada.dataInício = Convert.ToDateTime(Console.ReadLine());

            Console.Write("Data Final da Estada(YYYY-MM-DD HH:MM:SS): ");
            estada.dataFim = Convert.ToDateTime(Console.ReadLine());

            Console.Write("Tipo de Alojamento(tenda/bungalow): ");
            string tipoAloj = Console.ReadLine();

            Console.Write("Lotação de pessoas: ");
            int lot = int.Parse(Console.ReadLine());

            Console.Write("Identificador extra pessoal: ");
            extraPessoal.id        = int.Parse(Console.ReadLine());
            extraPessoal.associado = "pessoa";

            Console.Write("Identificador extra alojamento: ");
            extraAlojamento.id        = int.Parse(Console.ReadLine());
            extraAlojamento.associado = "alojamento";

            if (tipoAloj.Equals("tenda"))
            {
                using (Context context = new Context(connectionString)) {
                    Tenda tenda = new Tenda();
                    tenda.númeroMáximoPessoas = lot;
                    tenda.tipoAlojamento      = "tenda";
                    ProcUtils procedimento = new ProcUtils(context);
                    procedimento.createEstadaInTime(responsável, hóspede, estada, tenda, extraPessoal, extraAlojamento);
                }
            }
            else
            {
                using (Context context = new Context(connectionString)) {
                    Bungalow bungalow = new Bungalow();
                    bungalow.númeroMáximoPessoas = lot;
                    bungalow.tipoAlojamento      = "bungalow";
                    ProcUtils procedimento = new ProcUtils(context);
                    procedimento.createEstadaInTime(responsável, hóspede, estada, bungalow, extraPessoal, extraAlojamento);
                }
            }
        }
Beispiel #6
0
        public void UpdateTendaTest()
        {
            using (Context ctx = new Context(connectionString))
            {
                Parque parque = new Parque();
                parque.Nome     = "Marechal Carmona";
                parque.Morada   = "Rua de Cascais";
                parque.Estrelas = 4;
                parque.Email    = "*****@*****.**";

                ParqueMapper pm = new ParqueMapper(ctx);
                parque = pm.Create(parque);

                Alojamento alojamento = new Alojamento();
                alojamento.Nome        = "Primeiro Alojamento";
                alojamento.Localizaçao = "Quinta da Marinha";
                alojamento.Descrição   = "T0 com duche";
                alojamento.MaxPessoas  = 5;
                alojamento.PreçoBase   = 85;
                alojamento.Parque      = parque;

                AlojamentoMapper am = new AlojamentoMapper(ctx);
                alojamento = am.Create(alojamento);

                Tenda tenda = new Tenda();
                tenda.Area       = 1234;
                tenda.Alojamento = alojamento;
                tenda.Tipo       = "yurt";

                TendaMapper tendaMapper = new TendaMapper(ctx);
                tenda = tendaMapper.Create(tenda);

                tenda.Area = 5678;
                tenda.Tipo = "safari";
                tendaMapper.Update(tenda);

                Tenda tenda1 = tendaMapper.Read(tenda.Alojamento.Nome);

                Assert.AreEqual(tenda.Alojamento.Nome, tenda1.Alojamento.Nome);
                Assert.AreEqual(tenda.Tipo, tenda1.Tipo);

                foreach (var t in tendaMapper.ReadAll())
                {
                    tendaMapper.Delete(t);
                }
                foreach (var a in am.ReadAll())
                {
                    am.Delete(a);
                }
                foreach (var p in pm.ReadAll())
                {
                    pm.Delete(p);
                }
            }
        }
Beispiel #7
0
        protected override Tenda Map(IDataRecord record)
        {
            Tenda tenda = new Tenda();

            tenda.nomeParque          = record.GetString(0);
            tenda.nome                = record.GetString(1);
            tenda.localização         = record.GetString(2);
            tenda.descrição           = record.GetString(3);
            tenda.preçoBase           = record.GetInt32(4);
            tenda.númeroMáximoPessoas = record.GetByte(5);
            tenda.área                = record.GetInt32(6);

            return(tenda);
        }
Beispiel #8
0
        private static void DeleteTenda()
        {
            Tenda tenda = new Tenda();

            Console.Write("Nome do parque: ");
            tenda.nomeParque = Console.ReadLine();

            Console.Write("Localização: ");
            tenda.localização = Console.ReadLine();

            using (Context context = new Context(connectionString)) {
                TendaMapper tendaMapper = new TendaMapper(context);
                tendaMapper.Delete(tenda);
            }
        }
Beispiel #9
0
        protected override void UpdateParameters(IDbCommand command, Tenda e)
        {
            SqlParameter basePrice   = new SqlParameter("@preçoBase", e.preçoBase);
            SqlParameter description = new SqlParameter("@descrição", e.descrição);
            SqlParameter maxPeople   = new SqlParameter("@númeroMáximoPessoas", e.númeroMáximoPessoas);
            SqlParameter parkName    = new SqlParameter("@nomeParque", e.nomeParque);
            SqlParameter location    = new SqlParameter("@localização", e.localização);
            SqlParameter area        = new SqlParameter("@área", e.área);

            command.Parameters.Add(basePrice);
            command.Parameters.Add(description);
            command.Parameters.Add(maxPeople);
            command.Parameters.Add(parkName);
            command.Parameters.Add(location);
            command.Parameters.Add(area);
        }