partial void DeleteT_Address(T_Address instance);
Пример #2
0
		private Address GetAddressEntity(T_Address tAddress)
		{
			Address address = new Address();
			address.AddressID = tAddress.AddressID;
			address.City = tAddress.addrCity;
			address.Country.CountryID = tAddress.CountryID;
			address.State = tAddress.addrState;
			address.Street = tAddress.addrStreet;
			address.ZipCode = tAddress.addrZipCode;
			return address;
		}
 partial void UpdateT_Address(T_Address instance);
 partial void InsertT_Address(T_Address instance);
		private void detach_T_Addresses(T_Address entity)
		{
			this.SendPropertyChanging();
			entity.T_Country = null;
		}
Пример #6
0
		private Address GetAddressEntity(T_Address tAddress)
		{
			Address address = new Address();
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				address.AddressID = tAddress.AddressID;
				address.Street = tAddress.addrStreet;
				address.City = tAddress.addrCity;
				address.State = tAddress.addrState;
				address.ZipCode = tAddress.addrZipCode;
				address.Country = new Country() { Name = dc.T_Countries.First(el => el.CountryID == tAddress.CountryID).cntName, CountryID = tAddress.CountryID };
				address.Coords = tAddress.addrCoords;
				address.County = tAddress.addrCounty;
			}
			return address;
		}
Пример #7
0
		public int SaveAddress(Address entity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Address tAddress;
				if (!entity.AddressID.HasValue)
				{
					tAddress = new T_Address();
					dc.T_Addresses.InsertOnSubmit(tAddress);
				}
				else
				{
					tAddress = dc.T_Addresses.SingleOrDefault(a => a.AddressID == entity.AddressID);
					if (tAddress == null)
					{
						throw new ApplicationException("Address not found");
					}
				}
				tAddress.addrCity = entity.City;
				tAddress.addrCoords = entity.Coords;
				if (entity.Country != null)
				{
					tAddress.CountryID = dc.T_Countries.First(el => el.cntName == entity.Country.Name).CountryID;
				}
				tAddress.addrState = entity.State;
				tAddress.addrStreet = entity.Street;
				tAddress.addrZipCode = entity.ZipCode;
				tAddress.addrCounty = entity.County;
				dc.SubmitChanges();
				return tAddress.AddressID;
			}
		}