コード例 #1
0
        public ActionResult Create([Bind(Include = "Id,placa,modelo,marca,cor")] Carro carro, int?id)
        {
            HttpCookie myCookie = Request.Cookies["Loja"];

            carro.loja = LojaDAO.ProcurarbyId(Int32.Parse(myCookie.Values["lojaId"]));
            if (ModelState.IsValid)
            {
                Carro teste = CarrosDAO.ProcurarbyPlaca(carro.placa);
                if (teste == null)
                {
                    CarrosDAO.AdicionarNovo(carro);
                    ///fazer a relaçao
                    Carro             teste2 = CarrosDAO.ProcurarbyPlaca(carro.placa);
                    TabelaCarroPessoa t      = new TabelaCarroPessoa();
                    t.c           = teste2;
                    t.p           = PessoasDAO.ProcurarbyId(id);
                    t.dtaCadastro = DateTime.Now;
                    CarroPessoaDao.AdicionarNovo(t);
                    return(RedirectToAction("Index", "Pessoas"));
                }
                ModelState.AddModelError("", "Carro já Cadastrado");
                return(View());
            }

            return(View(carro));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Carro carro = CarrosDAO.ProcurarbyId(id);

            CarrosDAO.Remove(carro);
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        // GET: TabelaCarroPessoas/Create
        public ActionResult Create()
        {
            HttpCookie myCookie = Request.Cookies["Loja"];

            ViewBag.Carro  = CarrosDAO.ListarTodos(Int32.Parse(myCookie.Values["lojaId"]));
            ViewBag.Pessoa = PessoaLojaDAO.ListarTodasClientes(Int32.Parse(myCookie.Values["lojaId"]));
            return(View());
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,placa,modelo,marca,cor")] Carro carro)
 {
     if (ModelState.IsValid)
     {
         CarrosDAO.Editar(carro, carro.Id);
         return(RedirectToAction("Index"));
     }
     return(View(carro));
 }
コード例 #5
0
        // GET: Carroes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Carro carro = CarrosDAO.ProcurarbyId(id);

            if (carro == null)
            {
                return(HttpNotFound());
            }
            return(View(carro));
        }
コード例 #6
0
        // GET: Adm
        public ActionResult Index()
        {
            HttpCookie myCookie = Request.Cookies["Loja"];

            ViewBag.Clientes = PessoaLojaDAO.ListarTodasClientes(Int32.Parse(myCookie.Values["lojaId"]));
            ViewBag.Carros   = CarrosDAO.ListarTodos(Int32.Parse(myCookie.Values["lojaId"]));
            ViewBag.Pistas   = PistasDAO.ListarTodas(Int32.Parse(myCookie.Values["lojaId"]));
            ViewBag.Corridas = CorridaDAO.ProcurarbyAtivo(Int32.Parse(myCookie.Values["lojaId"]));
            //fazer um details
            // ViewBag.Composicao=ComposicaoDAO.ListarTodos();
            ViewBag.CarroPessoa = CarroPessoaDao.ListarTodos(Int32.Parse(myCookie.Values["lojaId"]));
            ViewBag.Horario     = HorarioPistaDAO.ListarTodos(Int32.Parse(myCookie.Values["lojaId"]));

            return(View());
        }
コード例 #7
0
        public ActionResult Create(int carroid, int pessoaid, TabelaCarroPessoa tabelaCarroPessoa)
        {
            Carro  c = CarrosDAO.ProcurarbyId(carroid);
            Pessoa p = PessoasDAO.ProcurarbyId(pessoaid);

            tabelaCarroPessoa.c           = c;
            tabelaCarroPessoa.p           = p;
            tabelaCarroPessoa.dtaCadastro = DateTime.Now;
            if (ModelState.IsValid)
            {
                TabelaCarroPessoa teste = CarroPessoaDao.ProcurarbyExitencia(tabelaCarroPessoa.c.Id, tabelaCarroPessoa.p.Id);
                if (teste == null)
                {
                    CarroPessoaDao.AdicionarNovo(tabelaCarroPessoa);
                    return(RedirectToAction("Index", "Home"));
                }

                return(RedirectToAction("Index", "Home"));
            }

            return(View(tabelaCarroPessoa));
        }
コード例 #8
0
        // GET: Carroes
        public ActionResult Index()
        {
            HttpCookie myCookie = Request.Cookies["Loja"];

            return(View(CarrosDAO.ListarTodos(Int32.Parse(myCookie.Values["lojaId"]))));
        }