예제 #1
0
 public void DeleteAddress(int ID)
 {
     Models.DBObjects.Address addressToDelete = dbContext.Addresses.FirstOrDefault(x => x.AddressID == ID);
     if (addressToDelete != null)
     {
         dbContext.Addresses.DeleteOnSubmit(addressToDelete);
         dbContext.SubmitChanges();
     }
 }
예제 #2
0
        public void UpdateAddress(AddressModel addressModel)
        {
            Models.DBObjects.Address existingAddress = dbContext.Addresses.FirstOrDefault(x => x.AddressID == addressModel.AddressID);
            if (existingAddress != null)
            {
                existingAddress.AddressID    = addressModel.AddressID;
                existingAddress.Country      = addressModel.Country;
                existingAddress.County       = addressModel.County;
                existingAddress.City         = addressModel.City;
                existingAddress.Street       = addressModel.Street;
                existingAddress.StreetNumber = addressModel.StreetNumber;
                existingAddress.PostCode     = addressModel.PostCode;

                dbContext.SubmitChanges();
            }
        }
예제 #3
0
        private Models.DBObjects.Address MapModelToDbObject(AddressModel addressModel)
        {
            Models.DBObjects.Address dbAddressModel = new Models.DBObjects.Address();
            if (addressModel != null)
            {
                dbAddressModel.AddressID    = addressModel.AddressID;
                dbAddressModel.Country      = addressModel.Country;
                dbAddressModel.County       = addressModel.County;
                dbAddressModel.City         = addressModel.City;
                dbAddressModel.Street       = addressModel.Street;
                dbAddressModel.StreetNumber = addressModel.StreetNumber;
                dbAddressModel.PostCode     = addressModel.PostCode;

                return(dbAddressModel);
            }
            return(null);
        }
예제 #4
0
        private AddressModel MapDbObjectToModel(Models.DBObjects.Address dbAddress)
        {
            AddressModel addressModel = new AddressModel();

            if (dbAddress != null)
            {
                addressModel.AddressID    = dbAddress.AddressID;
                addressModel.Country      = dbAddress.Country;
                addressModel.County       = dbAddress.County;
                addressModel.City         = dbAddress.City;
                addressModel.Street       = dbAddress.Street;
                addressModel.StreetNumber = dbAddress.StreetNumber;
                addressModel.PostCode     = dbAddress.PostCode;

                return(addressModel);
            }
            return(null);
        }