コード例 #1
0
 public ContactWithAddressDto GetContactWithAddressDto(Guid id)
 {
     using (var context = new ContactAggregateContext()) {
     Contact c = context.Contacts.Find(id);
     return ContactWithAddressDto.Create(c.Id, c.Name, c.PrimaryAddress, c.Source);
       }
 }
コード例 #2
0
        public bool PersistNewContact(Contact contact)
        {
            using (var context = new ContactAggregateContext()) {
            context.Contacts.Add(contact);
            contact.SetModifiedDate();

            try {
              int response = context.SaveChanges();
              if (response > 0) {
            PublishContactPersistedEvent(contact, true);
              }
              return true;
            }
            catch (Exception ex) {
              throw ex;
            }
              }
        }
コード例 #3
0
        public bool PersistNewContact(Contact contact)
        {
            using (var context = new ContactAggregateContext()) {
                context.Contacts.Add(contact);
                contact.SetModifiedDate();

                try {
                    int response = context.SaveChanges();
                    if (response > 0)
                    {
                        PublishContactPersistedEvent(contact, true);
                    }
                    return(true);
                }
                catch (Exception ex) {
                    throw ex;
                }
            }
        }
コード例 #4
0
 public bool PersistChangeToContact(Contact contact)
 {
     using (var context = new ContactAggregateContext()) {
     context.Contacts.Attach(contact);
     contact.SetModifiedDate();
     context.Entry(contact).State = EntityState.Modified;
     try {
       int response = context.SaveChanges();
       if (response > 0) {
     if (contact.Events.OfType<ContactNameFixedEvent>().Any()) {
       PublishContactPersistedEvent(contact, false);
     }
     return true;
       }
       return false;
     }
     catch (Exception ex) {
       throw ex;
     }
       }
 }
コード例 #5
0
 public bool PersistChangeToContact(Contact contact)
 {
     using (var context = new ContactAggregateContext()) {
         context.Contacts.Attach(contact);
         contact.SetModifiedDate();
         context.Entry(contact).State = EntityState.Modified;
         try {
             int response = context.SaveChanges();
             if (response > 0)
             {
                 if (contact.Events.OfType <ContactNameFixedEvent>().Any())
                 {
                     PublishContactPersistedEvent(contact, false);
                 }
                 return(true);
             }
             return(false);
         }
         catch (Exception ex) {
             throw ex;
         }
     }
 }
コード例 #6
0
 // GET api/<controller>/5
 public Address GetPrimaryAddressForContact(Guid id)
 {
     using (var context = new ContactAggregateContext()) {
     return context.Contacts.Find(id).PrimaryAddress;
       }
 }
コード例 #7
0
 // GET api/<controller>
 public IEnumerable<Contact> Get()
 {
     using (var context = new ContactAggregateContext()) {
     return context.Contacts.ToList();
       }
 }