예제 #1
0
        // GET api/<controller>
        public IHttpActionResult GetKeyData(int panelId)
        {
            using (dbMyHouseKeyEntities dc = new dbMyHouseKeyEntities())
            {
                var tbKeyList = (dynamic)null;
                if (panelId == 0)
                {
                    tbKeyList = dc.Tbl_Key.OrderBy(a => a.KeyName).ToList();
                }
                else
                {
                    tbKeyList = dc.Database.SqlQuery <Keys>("Select k.KeyId, KeyName, KeyDescription, KeyStatus from Tbl_PanelKey p inner join Tbl_Key k on p.KeyId = k.KeyId where p.PanelId =" + panelId);
                }
                List <Keys> keyList = new List <Keys>();
                foreach (var item in tbKeyList)
                {
                    Keys objPanel = new Keys();
                    objPanel.KeyId          = item.KeyId;
                    objPanel.KeyName        = item.KeyName;
                    objPanel.KeyDescription = item.KeyDescription;
                    objPanel.KeyStatusName  = Enum.GetName(typeof(KeyStatus), item.KeyStatus);
                    keyList.Add(objPanel);
                }

                return(Json(new { result = keyList }));
            }
        }
예제 #2
0
        // GET api/<controller>
        public IHttpActionResult GetPanelData()
        {
            using (dbMyHouseKeyEntities dc = new dbMyHouseKeyEntities())
            {
                var           tbPanelList = dc.Tbl_Panel.OrderBy(a => a.PanelName).ToList();
                List <Panels> panelList   = new List <Panels>();
                foreach (var item in tbPanelList)
                {
                    Panels objPanel = new Panels();
                    objPanel.PanelId     = item.PanelId;
                    objPanel.PanelName   = item.PanelName;
                    objPanel.PanelStatus = Enum.GetName(typeof(PanelStatus), item.PanelStatusId);
                    panelList.Add(objPanel);
                }

                return(Json(new { result = panelList }));;
            }
        }