Exemplo n.º 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);
            }
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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);
            }
        }