Пример #1
0
        //public long GetIdiomsCount()
        //{
        //    return _idioms.CountDocuments(new BsonDocument());
        //}

        public object GetIdiomById(string id, string sessionId, int bson)
        {
            Idiom raw = _idioms.Find(x => x.Id == id).FirstOrDefault();

            if (raw == null)
            {
                throw new EasyException(20001);
            }
            //return new StandardReturn(20001);
            if (Config.EnableProtection && _editors.Find(x => x.SessionId == sessionId).FirstOrDefault() == null)
            {
                List <Definition> defs     = raw.Definitions;
                List <Definition> modified = new();
                foreach (Definition def in defs)
                {
                    def.Source = "网络";
                    modified.Add(def);
                }
                raw.Definitions = modified;
            }
            if (bson == 1)
            {
                return(raw.ToBsonDocument().ToString());
            }
            //return new StandardReturn(result: raw.ToBsonDocument().ToString());
            return(raw);
            //return new StandardReturn(result: raw);
        }
Пример #2
0
        public ActionResult <string> GetBsonById(string id, string openId)
        {
            try
            {
                Idiom rtn = data.GetIdiomById(new ObjectId(id), openId);
                return(rtn.ToBsonDocument().ToString());
            }
            catch (System.Exception)
            {
                return(NotFound());

                throw;
            }
        }