public ActionResult Edit([Bind(Include = "Id,Nombre,Apodo,Fecha_nac,Sexo,Foto,ClienteId,RazaId")] MascotaViewModel mascotaVm) { if (ModelState.IsValid) { var mascota = mascotaVm.BindItem(); db.Entry(mascota).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClienteId = new SelectList(db.Users, "Id", "Nombre", mascotaVm.ClienteId); ViewBag.RazaId = new SelectList(db.Razas, "Id", "Nombre", mascotaVm.RazaId); return(View(mascotaVm)); }
public ActionResult Create([Bind(Include = "Id,Nombre,Apodo,Fecha_nac,Sexo,Foto,ClienteId,RazaId")] MascotaViewModel mascotaVm) { if (ModelState.IsValid) { var mascota = mascotaVm.BindItem(); mascota.Id = Guid.NewGuid(); db.Mascotas.Add(mascota); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.ClienteId = new SelectList(db.Users, "Id", "Nombre", mascotaVm.ClienteId); ViewBag.RazaId = new SelectList(db.Razas, "Id", "Nombre", mascotaVm.RazaId); ViewBag.ClienteId = User.Identity.Name; return(View(mascotaVm)); }