예제 #1
0
        public ActionResult Cadastro(ClienteViewModel clienteViewModel)
        {
            try
            {
                var newclienteViewModel   = new ClienteViewModelParser();
                var convertToCliente      = newclienteViewModel.clienteViewModelParser(clienteViewModel);
                var agendamentoRepository = new AgendamentosRepository();

                var resultDisponivel = agendamentoRepository.ValidarHorarioDisponivel(convertToCliente);

                if (clienteViewModel.AgendamentosViewModel.Count != convertToCliente.Agendamentos.Count)
                {
                    ViewData["mensagem"] = "<h1>Não foi possível cadastrar um Agendamento!</h1>";
                    return(View(clienteViewModel));
                }



                if (resultDisponivel && agendamentoRepository.Salvar(convertToCliente))
                {
                    ViewData["mensagem"] = "<h1>Agendamento Cadastrado com sucesso!</h1>";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewData["mensagem"] = "<h1>Agendamento Cadastrado com sucesso!</h1>";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #2
0
        public ActionResult Editar(ClienteViewModel clienteViewModel)
        {
            try
            {
                var newclienteViewModel   = new ClienteViewModelParser();
                var convertToCliente      = newclienteViewModel.clienteViewModelParser(clienteViewModel);
                var agendamentoRepository = new AgendamentosRepository();

                if (convertToCliente.Banda == null || convertToCliente.Agendamentos.Count == 0)
                {
                    ViewData["mensagem"] = "<h1>DEU RUIM</h1>";
                }

                else if (agendamentoRepository.Salvar(convertToCliente))
                {
                    ViewData["mensagem"] = "<h1>Agendamento alterado com sucesso!</h1>";
                }
                else
                {
                    ViewData["mensagem"] = "<h1>DEU RUIM</h1>";
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #3
0
        public string BuscarAgendamentosDiariosAutocomplete()
        {
            try
            {
                var agendamentoRepository = new AgendamentosRepository();

                var listaDeClientesDoBD = agendamentoRepository.BuscarAgendamentoDoDia();

                var jsonResult = JsonConvert.SerializeObject(listaDeClientesDoBD);


                return(jsonResult);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #4
0
        public string BuscarAgendamentosPorData(string value)
        {
            try
            {
                var agendamentoRepository = new AgendamentosRepository();

                var listaAgendamentosDoBD = agendamentoRepository.BuscarAgendamentosPorData(value);

                var jsonResult = JsonConvert.SerializeObject(listaAgendamentosDoBD);


                return(jsonResult);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #5
0
        public ActionResult Index()
        {
            try
            {
                var agendamentoRepository   = new AgendamentosRepository();
                var listaDeAgendamentosDoBD = agendamentoRepository.Listar();

                var clientViewModelParser = new ClienteViewModelParser();

                var model = new ClienteViewModel();
                model.AgendamentosViewModel = clientViewModelParser.ConvertClientToClienteViewModelList(listaDeAgendamentosDoBD);
                return(View(model));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #6
0
        public ActionResult Editar(int id)
        {
            try
            {
                var agendamentoRepository = new AgendamentosRepository();
                var result = agendamentoRepository.Carregar(id);

                var clientViewModelParser = new ClienteViewModelParser();
                var clientParsed          = clientViewModelParser.clienteParser(result);


                return(View(clientParsed));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #7
0
        public string BuscarAgendamentosAutocomplete(string value)
        {
            try
            {
                var split = value.Split('-');
                var id    = int.Parse(split[0]);

                var agendamentoRepository = new AgendamentosRepository();

                var listaDeClientesDoBD = agendamentoRepository.BuscarIdDaBanda(id);

                var jsonResult = JsonConvert.SerializeObject(listaDeClientesDoBD);


                return(jsonResult);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #8
0
        public ActionResult Detalhes(int id)
        {
            try
            {
                var agendamentoRepository = new AgendamentosRepository();
                var dadosCliente          = agendamentoRepository.Carregar(id);

                var clientViewModelParser = new ClienteViewModelParser();
                var clientParsed          = clientViewModelParser.clienteParser(dadosCliente);

                //  cliente = dadosCliente;
                // var result = agendamentoRepository.CarregarLista(cliente);
                // ViewBag.id = id;

                return(View(clientParsed));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #9
0
        public ActionResult Deletar(int id, FormCollection collection)
        {
            try
            {
                var agendamentoRepository = new AgendamentosRepository();


                if (agendamentoRepository.Excluir(id) == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    var result = agendamentoRepository.Carregar(id);
                    ViewData["mensagem"] = "<h1>DEU RUIM</h1>";
                    return(View(result));
                }
            }
            catch (Exception msg)
            {
                throw;
            }
        }