Beispiel #1
0
 //Method to create a new address
 public void CreateAddress(Address address)
 {
     using (TradingDatabaseEntities context = new TradingDatabaseEntities())
     {
         if (address == null)
         {
             context.Addresses.Add(address);
             context.SaveChanges();
         }
     }
 }
Beispiel #2
0
        //Method to update an existing address
        public void UpdateAddress(int id, Address newAddress)
        {
            using (TradingDatabaseEntities context = new TradingDatabaseEntities())
            {
                Address addressToUpdate = (from a in context.Addresses
                                           where a.ID == id
                                           select a).FirstOrDefault();
                if (newAddress != null)
                {
                    addressToUpdate.Line_1 = newAddress.Line_1;
                    addressToUpdate.Line_2 = newAddress.Line_2;
                    addressToUpdate.Line_3 = newAddress.Line_3;
                    addressToUpdate.City = newAddress.City;
                    addressToUpdate.Country = newAddress.Country;
                    addressToUpdate.Postcode = newAddress.Postcode;

                    context.SaveChanges();
                }
            }
        }
Beispiel #3
0
 //Update address
 public void UpdateAddress(int id, Address address)
 {
     db.UpdateAddress(id, address);
 }
Beispiel #4
0
 //Create address
 public void CreateAddress(Address address)
 {
     db.CreateAddress(address);
 }