public ActionResult Index() { SetupUnitModel model = new SetupUnitModel(); model.UnitLists = pro.GetList(); return(View(model)); }
public ActionResult Edit(int id) { SetupUnitModel model = new SetupUnitModel(); model = pro.GetList().Where(x => x.UnitId == id).FirstOrDefault(); return(View(model)); }
public int Insert(SetupUnitModel model) { using (EHMSEntities ent = new EHMSEntities()) { var objToSave = AutoMapper.Mapper.Map <SetupUnitModel, SetupUnit>(model); objToSave.Status = 1; ent.SetupUnits.Add(objToSave); ent.SaveChanges(); } return(1); }
public int Update(SetupUnitModel model) { using (EHMSEntities ent = new EHMSEntities()) { var objToEdit = ent.SetupUnits.Where(x => x.UnitId == model.UnitId).FirstOrDefault(); AutoMapper.Mapper.Map(model, objToEdit); ent.Entry(objToEdit).State = System.Data.EntityState.Modified; ent.SaveChanges(); } return(1); }
public ActionResult Edit(int id, SetupUnitModel model) { if (ModelState.IsValid) { int i = pro.Update(model); if (i == 1) { TempData["success"] = "Record Updated Successfully !"; } else { TempData["success"] = "Record Updation Failed !"; } return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create() { SetupUnitModel model = new SetupUnitModel(); return(View(model)); }