Ejemplo n.º 1
0
        public KeywordQueriedModels GetKeywordQueriedItemByKeywordId(long keywordId)
        {
            KeywordModels keywordObj    = GetKeywordItem(keywordId);
            long          queriedItemId = keywordObj.KeywordQueriedID;

            return(GetKeywordQueriedItem(queriedItemId));
        }
Ejemplo n.º 2
0
        public bool EditKeyword(KeywordSaveViewModel item)
        {
            KeywordQueriedModels queriedObj = GetKeywordQueriedItemByText(item.Text);

            if (queriedObj == null)
            {
                AddSingleKeywordQueried(item.Text, 0);
                queriedObj = GetKeywordQueriedItemByText(item.Text);
            }

            KeywordModels keywordExist = GetKeywordItemByText(item.Text);

            if (keywordExist != null && keywordExist.ID != item.ID)
            {
                return(false);
            }

            KeywordModels keywordObj = GetKeywordItem(item.ID ?? 0);

            SQLData.TableObject tableObj = GetTableObj("Keywords");
            tableObj.GetDataFromObject(keywordObj);

            tableObj["KeywordQueriedID"] = queriedObj.ID;
            tableObj["Modifier"]         = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
            tableObj["ModifyTime"]       = DateTime.Now;

            tableObj.Update(keywordObj.ID);
            return(true);
        }
Ejemplo n.º 3
0
        // 新增自定關鍵字
        public bool AddKeyword(KeywordSaveViewModel item)
        {
            SQLData.TableObject keywordTableObj = GetTableObj("Keywords");
            SQLData.TableObject queriedTableObj = GetTableObj("KeywordQueried");

            KeywordQueriedModels keywordQueriedObj = GetKeywordQueriedItemByText(item.Text);
            bool isNew = keywordQueriedObj == null;

            // 如果 KeywordQueried 沒有的話,Keywords、KeywordQueried 各 insert 一筆
            if (isNew)
            {
                queriedTableObj["Text"]  = item.Text;
                queriedTableObj["Count"] = 0;
                queriedTableObj.Insert();

                KeywordQueriedModels keyword = GetKeywordQueriedItemByText(item.Text);
                long keywordId = keyword.ID;

                int keywordCount   = (int)db.GetFirstValue(" SELECT count(*) FROM Keywords ");
                int maxKeywordSort = keywordCount == 0? 1: (int)db.GetFirstValue("SELECT Sort FROM Keywords ORDER BY Sort Desc");

                keywordTableObj["KeywordQueriedID"] = keywordId;
                keywordTableObj["Creator"]          = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                keywordTableObj["CreateTime"]       = DateTime.Now;
                keywordTableObj["IsIssue"]          = item.IsIssue;
                keywordTableObj["Sort"]             = maxKeywordSort + 1;
                keywordTableObj.Insert();

                return(true);
            }
            else
            {
                // 如果有的話,判斷是不是已經加入關鍵字
                KeywordModels keywordObj = GetKeywordItemByText(item.Text);

                // 已經加入的話就不加
                if (keywordObj != null)
                {
                    return(false);
                }

                int keywordCount   = (int)db.GetFirstValue(" SELECT count(*) FROM Keywords ");
                int maxKeywordSort = keywordCount == 0 ? 1 : (int)db.GetFirstValue("SELECT Sort FROM Keywords ORDER BY Sort Desc");

                keywordTableObj["KeywordQueriedID"] = keywordQueriedObj.ID;
                keywordTableObj["Modifier"]         = Areas.Backend.Models.DataAccess.MemberDAO.SysCurrent.Id;
                keywordTableObj["ModifyTime"]       = DateTime.Now;
                keywordTableObj["IsIssue"]          = item.IsIssue;
                keywordTableObj["Sort"]             = maxKeywordSort + 1;
                keywordTableObj.Insert();

                return(true);
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(long id)
        {
            KeywordQueriedModels queriedItem = keywordDao.GetKeywordQueriedItemByKeywordId(id);
            KeywordSaveViewModel model       = new KeywordSaveViewModel();
            KeywordModels        keyword     = keywordDao.GetKeywordItem(id);

            model.ID      = id;
            model.IsIssue = keyword.IsIssue;
            model.Text    = queriedItem.Text;

            return(View(model));
        }