示例#1
0
 public Address GetAddressByKey(int addrKey)
 {
     using (var context = new CustomerDbContext())
     {
         return(context.Addresses.FirstOrDefault(c => c.Key == addrKey));
     }
 }
示例#2
0
 public Customer GetCustomerWithAddressesByID(string custID)
 {
     using (var context = new CustomerDbContext())
     {
         return(context.Customers
                .Include(cust => cust.CustomerAddresses)
                .FirstOrDefault(c => c.Id == custID));
     }
 }
示例#3
0
 public Customer GetCustomerWithAddressesByKey(int custKey)
 {
     using (var context = new CustomerDbContext())
     {
         return(context.Customers
                .Include(g => g.Orders)
                .Include(i => i.CustomerAddresses)
                .ThenInclude(c => c.Address)
                .FirstOrDefault(p => p.Key == custKey));
     }
 }
示例#4
0
 public void AddAddress(Address data, int custKey = 0)
 {
     using (var context = new CustomerDbContext())
     {
         if (custKey == 0)
         {
         }
         else
         {
         }
     }
 }
示例#5
0
        public void UpdateAddress(Address address)
        {
            using (var context = new CustomerDbContext())
            {
                var addressToUpdate = context.Addresses.FirstOrDefault(c => c.Key == address.Key);
                if (addressToUpdate != null)
                {
                    addressToUpdate.Line1 = address.Line1;
                    addressToUpdate.Line2 = address.Line2;
                    addressToUpdate.City  = address.City;
                    addressToUpdate.State = address.State;
                    addressToUpdate.Zip   = address.Zip;

                    context.Addresses.Update(addressToUpdate);
                    context.SaveChanges();
                }
            }
        }