public ActionResult Edit(int ID) { try { var _editAonData = _entities.acq_department_master.Where(x => x.deptt_id == ID).FirstOrDefault(); DepartmentSaveViewModel model = new DepartmentSaveViewModel(); model.DeptId = _editAonData.deptt_id; model.DepartmentName = _editAonData.deptt_description; return(View(model)); } catch (Exception ex) { throw ex; } }
public ActionResult Update(DepartmentSaveViewModel model) { try { var _updateAon = _entities.acq_department_master.Where(x => x.deptt_id == model.DeptId).FirstOrDefault(); if (_updateAon != null) { _updateAon.deptt_description = model.DepartmentName; //_updateAon.Location = model.Location; _entities.SaveChanges(); } } catch (Exception ex) { throw ex; } return(Redirect("Index")); }
public ActionResult Create(DepartmentSaveViewModel model) { if (ModelState.IsValid) { try { acq_department_master obj = new acq_department_master(); obj.deptt_description = model.DepartmentName; _entities.acq_department_master.Add(obj); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; } } return(View()); }