public ActionResult SaveRecords(FormCollection model) { if (ModelState.IsValid) { using (usersCtl db = new usersCtl()){ var UseridArray = model.GetValues("item.Userid"); var EmailArray = model.GetValues("item.Email"); var PasswordArray = model.GetValues("item.Password"); var DevicetypeArray = model.GetValues("item.Devicetype"); var DeviceidArray = model.GetValues("item.Deviceid"); var IsactiveArray = model.GetValues("item.Isactive"); for (Int32 i = 0; i < UseridArray.Length; i++) { usersClass obj_update = db.selectById(Convert.ToInt32(UseridArray[i])); if (!string.IsNullOrEmpty(Convert.ToString(UseridArray))) { obj_update.Userid = Convert.ToInt32(UseridArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(EmailArray))) { obj_update.Email = Convert.ToString(EmailArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(PasswordArray))) { obj_update.Password = Convert.ToString(PasswordArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(DevicetypeArray))) { obj_update.Devicetype = Convert.ToString(DevicetypeArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(DeviceidArray))) { obj_update.Deviceid = Convert.ToString(DeviceidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(IsactiveArray))) { obj_update.Isactive = Convert.ToBoolean(IsactiveArray[i]); } db.update(obj_update); } } } return(RedirectToAction("EditTable")); }
public ActionResult Edit(usersClass Obj_users) { using (usersCtl db = new usersCtl()){ if (ModelState.IsValid) { db.update(Obj_users); string sesionval = Convert.ToString(Session["EditPreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("EditPreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } return(View(Obj_users)); } }