/// <summary> /// 获取所有待上线的项目 /// </summary> /// <returns></returns> public List <WaitUpModel> obtainAll() { List <WaitUpModel> agenters = new List <WaitUpModel>(); foreach (var record in _mongoCollection.FindAllAs <Object>().ToList()) { Dictionary <String, Object> dictionary = record.ToBsonDocument().ToDictionary(); WaitUpModel waitUpModel = new WaitUpModel(); agenters.Add(toEntity <WaitUpModel>(dictionary, waitUpModel)); } return(agenters); }
/// <summary> /// 删除一条数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public Stream deleteWaitUp(ImpContext context) { MongWaitUp mongWaitUp = new MongWaitUp(Constants.daname); //反序列化 WaitUpModel waitUpModel = JsonConvert.DeserializeObject <WaitUpModel>(context.json.Replace("\0", ""), new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); mongWaitUp.delete(waitUpModel); string pic = waitUpModel.pictiue.Replace("https://www.aikid360.com:8010/", ""); pic = string.Format("{0}{1}", @"C:\web\akidImg\", pic); if (File.Exists(pic)) { File.Delete(pic); } return(new ToStream().ToStreams(mongWaitUp.obtainAll())); }
/// <summary> /// 删除一条数据 /// </summary> /// <param name="agenter"></param> public void delete(WaitUpModel waitUpModel) { IMongoQuery query = Query.EQ("_id", waitUpModel._id); _mongoCollection.Remove(query); }