Ejemplo n.º 1
0
        public object Get(ZipResidents resident)
        {
            MongoCollection zipCollection = MongoDBHelper.GetCollection("fullstackdg", "zips");
            var             zipInfo       = zipCollection.FindOneByIdAs <ZipCodeInfo>(resident.ZipCode);

            return(zipInfo.Residents);
        }
Ejemplo n.º 2
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);
        }