Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "idAnimal,Esp_idEspecie,sex_idSexo,StA_idStatusAnimal")] Animal.Models.Animal animal, int[] TpI_idTipoIdentificador, string[] codigoIdentificador)
        {
            var teste = Request.Form;

            if (ModelState.IsValid)
            {
                db.Animal.Add(animal);
                for (int i = 0; i < TpI_idTipoIdentificador.Length; i++)
                {
                    db.IdentificadorAnimal.Add(new IdentificadorAnimal
                    {
                        Ani_idAnimal            = animal.idAnimal,
                        codigoIdentificador     = codigoIdentificador[i],
                        TpI_idTipoIdentificador = Convert.ToByte(TpI_idTipoIdentificador[i])
                    });
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Esp_idEspecie      = new SelectList(db.Especie, "idEspecie", "nomeVulgar", animal.Esp_idEspecie);
            ViewBag.sex_idSexo         = new SelectList(db.Sexo, "idSexo", "descricao", animal.sex_idSexo);
            ViewBag.StA_idStatusAnimal = new SelectList(db.StatusAnimal, "idStatusAnimal", "descricao", animal.StA_idStatusAnimal);
            return(View(animal));
        }
Exemplo n.º 2
0
 public ActionResult DeleteConfirmed(int id)
 {
     Animal.Models.Animal animal = db.Animal.Find(id);
     db.Animal.Remove(animal);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 3
0
 // GET: Animal/Details/5
 public ActionResult Details(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Animal.Models.Animal animal = db.Animal.Find(id);
     if (animal == null)
     {
         return(HttpNotFound());
     }
     return(View(animal));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "idAnimal,Esp_idEspecie,sex_idSexo,StA_idStatusAnimal")] Animal.Models.Animal animal)
 {
     if (ModelState.IsValid)
     {
         db.Entry(animal).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Esp_idEspecie      = new SelectList(db.Especie, "idEspecie", "nomeVulgar", animal.Esp_idEspecie);
     ViewBag.sex_idSexo         = new SelectList(db.Sexo, "idSexo", "descricao", animal.sex_idSexo);
     ViewBag.StA_idStatusAnimal = new SelectList(db.StatusAnimal, "idStatusAnimal", "descricao", animal.StA_idStatusAnimal);
     return(View(animal));
 }
Exemplo n.º 5
0
 // GET: Animal/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Animal.Models.Animal animal = db.Animal.Find(id);
     if (animal == null)
     {
         return(HttpNotFound());
     }
     ViewBag.Esp_idEspecie      = new SelectList(db.Especie, "idEspecie", "nomeVulgar", animal.Esp_idEspecie);
     ViewBag.sex_idSexo         = new SelectList(db.Sexo, "idSexo", "descricao", animal.sex_idSexo);
     ViewBag.StA_idStatusAnimal = new SelectList(db.StatusAnimal, "idStatusAnimal", "descricao", animal.StA_idStatusAnimal);
     return(View(animal));
 }