Ejemplo n.º 1
0
        public ActionResult ChangeState(int nodeId, bool IsStart)
        {
            if (Session["UserId"] != null)
            {
                try
                {
                    int userId = Convert.ToInt32(Session["UserId"].ToString());
                    int i      = 0;
                    //var node = _nodeService.GetNodeByNodeId(nodeId);
                    //if (!node.IsStart)
                    //{
                    //    i = _nodeService.UpdateNodeStatus(nodeId,true);
                    //}
                    //else
                    //{
                    i = _nodeService.UpdateNodeStatus(nodeId, IsStart?false:true);
                    //}

                    if (i > 0)
                    {
                        int j = _nodeService.AddNodeLogs(nodeId, userId, IsStart?"Off":"On");
                        if (j > 0)
                        {
                            return(Json("SUCCESS", JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            return(Json("Some Problem in Changing State", JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        return(Json("Some Problem in Changing State", JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception rx)
                {
                    throw rx;
                }
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }