public TbType ConvertTyp(TypViewModel tbtype) { return new TbType() { TbTypeID = tbtype.TypID, Name = tbtype.TypName }; }
public ActionResult Create(TypViewModel tbtype) { var typ = convert.ConvertTyp(tbtype); if (ModelState.IsValid) { db.TbTypes.Add(typ); db.SaveChanges(); return RedirectToAction("Index1"); } return View(typ); }
public ActionResult Edit(TypViewModel tbtype) { if (ModelState.IsValid) { TbType tbtypeOrg = db.TbTypes.First(p => p.TbTypeID == tbtype.TypID); tbtypeOrg.Name = tbtype.TypName; db.SaveChanges(); return RedirectToAction("Index1"); } return View(tbtype); }
// // GET: /TbType/ public ViewResult Index1() { var mymodel = new TypViewModel(); mymodel.TypAll = db.TbTypes.ToList(); return View(mymodel); }