Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Telefone,RG,DataNascimento,Logradouro,Bairro,Cidade,Estado")] Hospede hospede)
        {
            if (id != hospede.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hospede);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HospedeExists(hospede.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hospede));
        }
Пример #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Hospede hospede = await _context.Hospede.FindAsync(id);

            _context.Hospede.Remove(hospede);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,Nome,Telefone,RG,DataNascimento,Logradouro,Bairro,Cidade,Estado")] Hospede hospede)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hospede);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hospede));
        }
Пример #4
0
        // GET: Hospedes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Hospede hospede = db.Hospedes.Find(id);

            if (hospede == null)
            {
                return(HttpNotFound());
            }
            return(View(hospede));
        }
Пример #5
0
 public ActionResult Delete(int id)
 {
     try
     {
         Hospede hospede = db.Hospedes.Find(id);
         db.Hospedes.Remove(hospede);
         db.SaveChanges();
     }
     catch (DataException /* dex */)
     {
         return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
     }
     return(RedirectToAction("Index"));
 }
Пример #6
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Hospede hospede = await _context.Hospede.FindAsync(id);

            if (hospede == null)
            {
                return(NotFound());
            }

            return(View(hospede));
        }
Пример #7
0
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Hospede hospede = await _context.Hospede
                              .FirstOrDefaultAsync(h => h.Id == id);

            if (hospede == null)
            {
                return(NotFound());
            }

            return(View(hospede));
        }
Пример #8
0
 public BaseServiceTest()
 {
     fixture                  = new Fixture();
     _request                 = fixture.Create <ObterReservasRequest>();
     _hospedesRepository      = Substitute.For <IHospedesRepository>();
     _reservasRepository      = Substitute.For <IReservasRepository>();
     _acompanhantesRepository = Substitute.For <IAcompanhantesRepository>();
     _logger                  = Substitute.For <ILogger <ReservasService> >();
     _configuration           = Substitute.For <IConfiguration>();
     _mapper                  = Substitute.For <IMapper>();
     _hospedeDto              = fixture.Create <HospedeDto>();
     _hospede                 = fixture.Create <Hospede>();
     _acompanhante            = fixture.Create <List <Acompanhante> >();
     _reserva                 = fixture.Create <List <Reserva> >();
     _reservaDto              = fixture.Create <IEnumerable <ReservaDto> >();
     _acompanhanteDto         = fixture.Create <IEnumerable <AcompanhanteDto> >();
     _service                 = new ReservasService(_logger, _configuration, _mapper, _reservasRepository, _hospedesRepository, _acompanhantesRepository);
 }
Пример #9
0
        public ActionResult Create([Bind(Include = "Nome, Sobrenome, Email, CPF, Endereco")] Hospede hospede)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Hospedes.Add(hospede);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                ModelState.AddModelError("", "Nao foi possicel criar um novo hospede, se o problema persistir, contacte o Administrador do sistema.");
            }

            return(View(hospede));
        }
Пример #10
0
        // GET: Hospedes/Delete/5
        public ActionResult Delete(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Nao foi possicel alterar o hospede, se o problema persistir, contacte o Administrador do sistema.";
            }
            Hospede hospede = db.Hospedes.Find(id);

            if (hospede == null)
            {
                return(HttpNotFound());
            }
            return(View(hospede));
        }
Пример #11
0
        public static bool PrintTelaNovaReserva(string message = "")
        {
            try
            {
                if (message != "")
                {
                    Console.WriteLine(message);
                }

                var cliente = new ConsultaCPF();

                Console.Clear();
                Console.WriteLine("----------- HOTEL BONSOIR - MANAGEMENT -----------");
                Console.WriteLine();
                Console.WriteLine("Realizar Nova Reserva - Selecionar Cliente:");
                Console.WriteLine("Insira um CPF Válido:");
                string cpf      = "";
                var    cpfCheck = false;
                while (!cpfCheck)
                {
                    cpf      = Console.ReadLine();
                    cpfCheck = ServicoReserva.VerificarCpf(cpf);
                    if (cpfCheck == false)
                    {
                        Console.WriteLine();
                        Console.WriteLine("CPF Inválido:");
                        Console.WriteLine();
                        Console.WriteLine("Deseja Cancelar Operação? (S/N)");
                        if (char.Parse(Console.ReadLine()) == 's')
                        {
                            return(false);
                        }
                    }
                    cliente = ServicoCliente.ObterPorCPF(cpf);
                    if (cliente.CPF != null)
                    {
                        Console.Clear();
                        Console.WriteLine("----------- HOTEL BONSOIR - MANAGEMENT -----------");
                        Console.WriteLine();
                        Console.WriteLine("Cliente Ja Cadastrado:");
                        PrintTelaUnicoCliente(cliente.CPF);
                        Console.WriteLine();
                        Console.WriteLine("Pressione Enter Para Continuar");
                        Console.ReadLine();
                    }
                    else
                    {
                        bool cadastroStatus = false;
                        while (!cadastroStatus)
                        {
                            Console.WriteLine("Redirecionando Para Novo Cadastro");
                            System.Threading.Thread.Sleep(2000);
                            cadastroStatus = PrintTelaCadastroCliente(cpf);
                        }
                    }
                    Console.Clear();
                    Console.WriteLine("----------- HOTEL BONSOIR - MANAGEMENT -----------");
                    Console.WriteLine();
                    Console.WriteLine("Realizar Nova Reserva - Selecionar Quarto:");
                    var novaReserva = new CadastrarNova();
                    novaReserva.CPF = cpf;
                    Console.WriteLine("Selecione Um quarto Tipo de Quarto: (1 - Casal/2 - Simples/3 - Duplo)");
                    PrintTelaQuartos("Livre", int.Parse(Console.ReadLine()));
                    Console.WriteLine("----------------------------------");
                    Console.WriteLine();
                    Console.WriteLine("Digite o Número do Quarto Desejado: ");
                    novaReserva.QuartoId = int.Parse(Console.ReadLine());
                    Console.Clear();
                    Console.WriteLine("----------- HOTEL BONSOIR - MANAGEMENT -----------");
                    Console.WriteLine();
                    Console.WriteLine("Data de CheckIn (dd/MM/yyyy): ");
                    novaReserva.CheckIn = DateTime.Parse(Console.ReadLine());
                    Console.WriteLine("Data de CheckOut (dd/MM/yyyy): ");
                    novaReserva.CheckOut = DateTime.Parse(Console.ReadLine());
                    Console.WriteLine("Digite o Numero de Hospedes: ");
                    int            numHospedes = int.Parse(Console.ReadLine());
                    List <Hospede> listaAux    = new List <Hospede>();
                    for (int i = 0; i < numHospedes; i++)
                    {
                        var hospede = new Hospede();
                        Console.WriteLine($"Digite o Numero do CPF do Hospede {i}: ");
                        hospede.CPF = Console.ReadLine();
                        listaAux.Add(hospede);
                    }
                    novaReserva.Hospedes = listaAux;
                    Console.WriteLine();
                    Console.WriteLine("Pressione Enter Para Continuar");
                    ServicoReserva.CadastrarNovaReserva(novaReserva);
                    Console.Clear();
                    Console.WriteLine("----------- HOTEL BONSOIR - MANAGEMENT -----------");
                    Console.WriteLine();
                    PrintTelaReserva(novaReserva);
                    Console.WriteLine("Pressione Enter Para Continuar");
                    Console.ReadLine();
                    return(true);
                }
            }
            catch (ReservaExceptions e)
            {
                Console.WriteLine();
                Console.WriteLine("Deseja Cancelar Operação? (S/N)");
                if (char.Parse(Console.ReadLine()) == 's')
                {
                    return(false);
                }
                else
                {
                    PrintTelaNovaReserva(e.Message);
                }
            }
            return(true);
        }
Пример #12
0
 public static bool AddHospedes(Hospede x)
 {
     hospedes.Add(x);
     return(true);
 }