public void AddPart(EngParts part) { using (Eng_PartEntities db = new Eng_PartEntities()) { ModulePart mp = new ModulePart(); mp.PartName = part.PartName; mp.PartDesc = part.PartDesc; mp.PartDimension = part.PartDimension; mp.PartMetal = part.PartMetal; mp.PartCDate = DateTime.Now; mp.PartMDate = DateTime.Now; db.ModuleParts.Add(mp); db.SaveChanges(); } }
public ActionResult CreatePart(EngParts part) { if (ModelState.IsValid) { PartManager pm = new PartManager(); pm.AddPart(part); // RedirectToAction("ListPart"); return(RedirectToAction("ListPart", "Home")); } else { ModelState.AddModelError("", "* Enter required fields"); } return(View()); }