public ActionResult EditTrain(Train train) { try { if (ModelState.IsValid) { using (SmartMonitoringEntities context = new SmartMonitoringEntities()) { int i = context.AddTrain("UPDATE", Session["UserID"].ToString(), Session["SelectedNodeID"].ToString(), train.TrainName, train.NumberOfMachines, train.DriveUnitName, train.IntermediateUnitName, train.DrivenUnitName, Session["UserRole"].ToString(), train.ParentID); if (i > 0) { return(RedirectToAction("PlantIndex")); } } return(RedirectToAction("PlantIndex")); } else { ModelState.AddModelError("", "Your data is not changed successfully! Please try again."); } } catch (Exception ex) { throw ex; } return(RedirectToAction("PlantIndex")); }
public ActionResult AddTrain(Train train, FormCollection form) { try { if (ModelState.IsValid) { string paranetid = form["parentid"]; using (SmartMonitoringEntities context = new SmartMonitoringEntities()) { int i = context.AddTrain("INSERT", Session["UserID"].ToString(), train.TrainID, train.TrainName, train.NumberOfMachines, train.DriveUnitName, train.IntermediateUnitName, train.DrivenUnitName, Session["UserRole"].ToString(), paranetid); if (i > 0) { return(RedirectToAction("PlantIndex")); } var list = new System.Collections.Generic.List <Object> { "1',2" }; } return(RedirectToAction("PlantIndex")); } else { ModelState.AddModelError("", "Fill all fields correctly !"); } } catch (Exception ex) { throw ex; } return(RedirectToAction("PlantIndex")); }