Пример #1
0
 public ActionResult EditPoint(Point point)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (SmartMonitoringEntities context = new SmartMonitoringEntities())
             {
                 int i = context.AddPoint("UPDATE", Session["UserID"].ToString(), Session["SelectedNodeID"].ToString(), point.PointName, point.PointDetails, point.NoOfSensors, Session["UserRole"].ToString(), point.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"));
 }
Пример #2
0
 public ActionResult AddPoint(Point point, FormCollection form)
 {
     try
     {
         if (ModelState.IsValid)
         {
             string parentid = form["parentid"];
             using (SmartMonitoringEntities context = new SmartMonitoringEntities())
             {
                 int i = context.AddPoint("INSERT", Session["UserID"].ToString(), point.PointID, point.PointName, point.PointDetails, point.NoOfSensors, Session["UserRole"].ToString(), parentid);
                 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"));
 }