コード例 #1
0
        public void Delete(MongoPerson item)
        {
            MongoDatabase db = server.GetDatabase("Person");
            var people = db.GetCollection<MongoPerson>("Person");
            //people.Find(item);

        }
コード例 #2
0
ファイル: PersonServices.cs プロジェクト: MGnuskina/Tasks
 private PersonViewModel ToViewModel(MongoPerson personR)
 {
     PersonViewModel personVM = new PersonViewModel()
     {
         Id = personR.Id,
         FirstName = personR.FirstName,
         LastName = personR.LastName,
         Age = personR.Age,
         PhoneNumbers = new List<PhoneNumberViewModel>()
     };
     foreach (var pn in personR.phonenumbers)
     {
         personVM.PhoneNumbers.Add(new PhoneNumberViewModel()
         {
             Id = pn.Id,
             PhoneNumber = pn.PhoneNumber,
             PhoneNumberType = pn.PhoneNumberType
         });
     }
     return personVM;
 }
コード例 #3
0
 public void Create(MongoPerson item)
 {
     MongoPerson person = new MongoPerson()
     {
         FirstName = item.FirstName,
         LastName = item.LastName,
         Age = item.Age,
         Id=new ObjectId(),
         phonenumbers = new List<MongoPhoneNumber>()//for one number
         {
             new MongoPhoneNumber()
             {
                 Id=new ObjectId(),
                 PhoneNumber=item.phonenumbers[0].PhoneNumber,
                 PhoneNumberType=item.phonenumbers[0].PhoneNumberType
             }
         }
     };
     MongoDatabase db = server.GetDatabase("Person");
     var people = db.GetCollection<MongoPerson>("Person");
     people.Save(person);
 }
コード例 #4
0
ファイル: PersonServices.cs プロジェクト: MGnuskina/Tasks
 private MongoPerson FromViewModel(PersonViewModel person)
 {
     MongoPerson personR = new MongoPerson()
     {
         Id = person.Id,
         FirstName = person.FirstName,
         LastName = person.LastName,
         Age = person.Age,
         phonenumbers = new List<MongoPhoneNumber>()
     };
     foreach (var pn in person.PhoneNumbers)
     {
         if (pn.PhoneNumberType==null)
         {
             throw new ArgumentException();
         }
         personR.phonenumbers.Add(new MongoPhoneNumber()
         {
             Id=pn.Id,
             PhoneNumber = pn.PhoneNumber,
             PhoneNumberType=pn.PhoneNumberType,
         });
     }
     return personR;
 }
コード例 #5
0
 public void Update(MongoPerson item)
 {
     throw new NotImplementedException();
 }