public ActionResult DeleteConfirmed(int id) { ms_asset_register_location ms_asset_register_location = db.ms_asset_register_location.Find(id); db.ms_asset_register_location.Remove(ms_asset_register_location); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "asset_reg_location_id,asset_reg_location_code,asset_reg_location_name,fl_active,created_date,created_by,updated_date,updated_by,deleted_date,deleted_by,org_id")] ms_asset_register_location ms_asset_register_location) { if (ModelState.IsValid) { db.Entry(ms_asset_register_location).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ms_asset_register_location)); }
// GET: asset_register_location/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ms_asset_register_location ms_asset_register_location = db.ms_asset_register_location.Find(id); if (ms_asset_register_location == null) { return(HttpNotFound()); } return(View(ms_asset_register_location)); }
public JsonResult CrudAssetRegLoc() { if (UserProfile.UserId != 0) { if (Request.Form["oper"] == "add") { //prepare for insert data ms_asset_register_location ms_asset_reg_loc = new ms_asset_register_location(); ms_asset_reg_loc.asset_reg_location_code = Request.Form["asset_reg_location_code"]; ms_asset_reg_loc.asset_reg_location_name = Request.Form["asset_reg_location_name"]; ms_asset_reg_loc.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; ms_asset_reg_loc.created_by = UserProfile.UserId; ms_asset_reg_loc.created_date = DateTime.Now; ms_asset_reg_loc.updated_by = UserProfile.UserId; ms_asset_reg_loc.updated_date = DateTime.Now; ms_asset_reg_loc.org_id = UserProfile.OrgId; ms_asset_reg_loc.deleted_by = null; ms_asset_reg_loc.deleted_date = null; db.Entry(ms_asset_reg_loc).State = EntityState.Added; db.SaveChanges(); return(Json("Insert", JsonRequestBehavior.AllowGet)); } else if (Request.Form["oper"] == "edit") { if (IsNumeric(Request.Form["asset_reg_location_id"].ToString())) { //prepare for update data int id = Convert.ToInt32(Request.Form["asset_reg_location_id"]); ms_asset_register_location ms_asset_reg_loc = db.ms_asset_register_location.Find(id); ms_asset_reg_loc.asset_reg_location_code = Request.Form["asset_reg_location_code"]; ms_asset_reg_loc.asset_reg_location_name = Request.Form["asset_reg_location_name"]; ms_asset_reg_loc.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; ms_asset_reg_loc.updated_by = UserProfile.UserId; ms_asset_reg_loc.updated_date = DateTime.Now; db.Entry(ms_asset_reg_loc).State = EntityState.Modified; db.SaveChanges(); return(Json("Update", JsonRequestBehavior.AllowGet)); } else { //prepare for insert data ms_asset_register_location ms_asset_reg_loc = new ms_asset_register_location(); ms_asset_reg_loc.asset_reg_location_code = Request.Form["asset_reg_location_code"]; ms_asset_reg_loc.asset_reg_location_name = Request.Form["asset_reg_location_name"]; ms_asset_reg_loc.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; ms_asset_reg_loc.created_by = UserProfile.UserId; ms_asset_reg_loc.created_date = DateTime.Now; ms_asset_reg_loc.updated_by = UserProfile.UserId; ms_asset_reg_loc.updated_date = DateTime.Now; ms_asset_reg_loc.org_id = UserProfile.OrgId; ms_asset_reg_loc.deleted_by = null; ms_asset_reg_loc.deleted_date = null; db.Entry(ms_asset_reg_loc).State = EntityState.Added; db.SaveChanges(); return(Json("Insert", JsonRequestBehavior.AllowGet)); } } else { if (Request.Form["oper"] == "del") { //for delete process string ids = Request.Form["id"]; string[] values = ids.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); //prepare for soft delete data int id = Convert.ToInt32(values[i]); ms_asset_register_location ms_asset_reg_loc = db.ms_asset_register_location.Find(id); ms_asset_reg_loc.fl_active = false; ms_asset_reg_loc.deleted_by = UserProfile.UserId; ms_asset_reg_loc.deleted_date = DateTime.Now; db.Entry(ms_asset_reg_loc).State = EntityState.Modified; db.SaveChanges(); } return(Json("Delete", JsonRequestBehavior.AllowGet)); } else { return(Json("Error", JsonRequestBehavior.AllowGet)); } } } else { return(Json("Session", JsonRequestBehavior.AllowGet)); } }