コード例 #1
0
ファイル: MongoDBListStorage.cs プロジェクト: kwaazaar/lists
        public async Task <model.ListModel> AddList(string userId, model.ListModel list)
        {
            var insertOptions = new InsertOneOptions
            {
                BypassDocumentValidation = false,
            };

            var storageList = list.Map(userId);
            await MongoDbUtil.GetCollection <List>(DBNAME, COLLECTION_LIST).InsertOneAsync(storageList, insertOptions);

            return(list);
        }
コード例 #2
0
 public static storage.List Map(this model.ListModel list, string userId)
 {
     return(new storage.List()
     {
         UserId = userId,
         Id = list.Id,
         Name = list.Name,
         Items = list.Items.Select(li => new storage.ListItem()
         {
             Id = li.Id,
             Question = li.Question,
             Answer = li.Answer,
         }).ToList(),
     });
 }