Ejemplo n.º 1
0
        public string KouForgetAnotherName(string NameOrID)
        {
            if (NameOrID.IsNullOrWhiteSpace())
            {
                return("这是叫我忘掉什么嘛");
            }
            PluginArcaeaSongAnotherName songAnotherName;

            if (int.TryParse(NameOrID, out int ID))
            {
                songAnotherName = _kouContext.Set <PluginArcaeaSongAnotherName>().SingleOrDefault(x => x.AnotherNameId == ID);
            }
            else if (_kouContext.Set <PluginArcaeaSongAnotherName>().Any(x => x.AnotherName == NameOrID))
            {
                var names = _kouContext.Set <PluginArcaeaSongAnotherName>().Where(x => x.AnotherName == NameOrID);
                if (names.Count() > 1)
                {
                    return($"具体是删除哪个?\n{names.ToSetString<PluginArcaeaSongAnotherName>()}");
                }
                songAnotherName = names.First();
            }
            else
            {
                return("我没学过这个的吧");
            }
            _kouContext.Remove(songAnotherName);
            return(_kouContext.SaveChanges() > 0 ? "忘掉了" : "...不知道为什么忘不掉");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除罗马音-谐音键值对
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeletePair(int id)
        {
            var pair = kouContext.Set <RomajiPair>().SingleOrDefault(x => x.Id == id);

            if (pair == null)
            {
                return(false);
            }
            kouContext.Remove(pair);
            RomajiToZhDict.Remove(pair.RomajiKey);
            return(kouContext.SaveChanges() > 0);
        }