public ActionResult Create(ManzanaViewModels model) { if (ModelState.IsValid) { Manzana.NombreManzana = model.NombreManzana; dbCtx.Manzana.Add(Manzana); dbCtx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(ManzanaViewModels model) { if (ModelState.IsValid) { Manzana = dbCtx.Manzana.FirstOrDefault(a => a.Id == model.Id); Manzana.NombreManzana = model.NombreManzana; dbCtx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { ViewBag.Title = "Editar Manzana"; ManzanaViewModels manzana = new ManzanaViewModels(); Manzana = dbCtx.Manzana.FirstOrDefault(a => a.Id == id); manzana.Id = Manzana.Id; manzana.NombreManzana = Manzana.NombreManzana; return(View(manzana)); }
public ActionResult Delete(ManzanaViewModels model) { var manzana = (from p in dbCtx.Manzana where p.Id == model.Id select p).FirstOrDefault(); dbCtx.Manzana.Remove(manzana); int num = dbCtx.SaveChanges(); if (num > 0) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); } return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); }