public ActionResult Edit(locationphotoClass Obj_locationphoto) { using (locationphotoCtl db = new locationphotoCtl()){ if (ModelState.IsValid) { db.update(Obj_locationphoto); string sesionval = Convert.ToString(Session["EditPreviousURL"]); if (!string.IsNullOrEmpty(sesionval)) { Session.Remove("EditPreviousURL"); return(Redirect(sesionval)); } else { return(RedirectToAction("Index")); } } return(View(Obj_locationphoto)); } }
public ActionResult SaveRecords(FormCollection model) { if (ModelState.IsValid) { using (locationphotoCtl db = new locationphotoCtl()){ var LocationphotoidArray = model.GetValues("item.Locationphotoid"); var PhotoArray = model.GetValues("item.Photo"); var LocationidArray = model.GetValues("item.Locationid"); var PhotodescriptionArray = model.GetValues("item.Photodescription"); var PhotouploadeddateArray = model.GetValues("item.Photouploadeddate"); var BuildingidArray = model.GetValues("item.Buildingid"); var BuildingdeficiencyrepairidArray = model.GetValues("item.Buildingdeficiencyrepairid"); var BuildingworkorderidArray = model.GetValues("item.Buildingworkorderid"); var WorkorderfollowupidArray = model.GetValues("item.Workorderfollowupid"); var UseridArray = model.GetValues("item.Userid"); var InserteddatetimeArray = model.GetValues("item.Inserteddatetime"); for (Int32 i = 0; i < LocationphotoidArray.Length; i++) { locationphotoClass obj_update = db.selectById(Convert.ToInt32(LocationphotoidArray[i])); if (!string.IsNullOrEmpty(Convert.ToString(LocationphotoidArray))) { obj_update.Locationphotoid = Convert.ToInt32(LocationphotoidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(PhotoArray))) { obj_update.Photo = Convert.To(PhotoArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(LocationidArray))) { obj_update.Locationid = Convert.ToInt32(LocationidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(PhotodescriptionArray))) { obj_update.Photodescription = Convert.ToString(PhotodescriptionArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(PhotouploadeddateArray))) { obj_update.Photouploadeddate = Convert.ToDateTime(PhotouploadeddateArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(BuildingidArray))) { obj_update.Buildingid = Convert.ToInt32(BuildingidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(BuildingdeficiencyrepairidArray))) { obj_update.Buildingdeficiencyrepairid = Convert.ToInt32(BuildingdeficiencyrepairidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(BuildingworkorderidArray))) { obj_update.Buildingworkorderid = Convert.ToInt32(BuildingworkorderidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(WorkorderfollowupidArray))) { obj_update.Workorderfollowupid = Convert.ToInt32(WorkorderfollowupidArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(UseridArray))) { obj_update.Userid = Convert.ToInt32(UseridArray[i]); } if (!string.IsNullOrEmpty(Convert.ToString(InserteddatetimeArray))) { obj_update.Inserteddatetime = Convert.ToDateTime(InserteddatetimeArray[i]); } db.update(obj_update); } } } return(RedirectToAction("EditTable")); }