Пример #1
0
        public void Post(ZipResidents resident)
        {
            Console.WriteLine(resident.ZipCode);
            MongoCollection zipCollection = MongoDBHelper.GetCollection("fullstackdg", "zips");
            var             zipInfo       = zipCollection.FindOneByIdAs <ZipCodeInfo>(resident.ZipCode);

            if (zipInfo.Residents == null)
            {
                zipInfo.Residents = new List <Resident>();
            }
            zipInfo.Residents.Add(new Resident {
                Name = resident.Name, Title = resident.Title
            });
            zipCollection.Save(zipInfo);
        }