public void SaveAddress(Address address)
        {
            if (address.AddressID == 0)
            {

                address.CreatedAt = DateTime.Now;
                address.UpdatedAt = DateTime.Now;
                context.Addresses.Add(address);
            }
            else
            {
                Address dbEntry = context.Addresses.Find(address.AddressID);
                if (dbEntry != null)
                {
                    dbEntry.StreetLine1 = address.StreetLine1;
                    dbEntry.StreetLine2 = address.StreetLine2;
                    dbEntry.StreetLine3 = address.StreetLine3;
                    dbEntry.City = address.City;
                    dbEntry.County = address.County;
                    dbEntry.Country = address.Country;
                    dbEntry.PostalCode = address.PostalCode;
                    dbEntry.UpdatedAt = DateTime.Now;
                }
            }
            context.SaveChanges();
        }
 public ViewResult Create()
 {
     Address address = new Address();
     ViewBag.CustomerID = GetCustomerIDs(address);
     return View("Edit", address);
 }
 private int GetCustomerID(Address address)
 {
     int custID = 0;
     int userID = WebSecurity.CurrentUserId;
     IEnumerable<Customer> customers = repositoryCustomer.Customers.Where(x => x.UserID == userID);
     foreach (var customer in customers) {
         custID = customer.CustomerID;
     }
     return custID;
 }
 private SelectList GetCustomerIDs(Address address)
 {
     int userID = WebSecurity.CurrentUserId;
     return new SelectList(repositoryCustomer.Customers.Where(x => x.UserID == userID), "CustomerID", "CustomerID", address.CustomerID);
 }