public AddressContactModel GetContactPerson(Int32 userPersonalInfoId) { AddressContactModel contact = new AddressContactModel(); String query = $"SELECT * FROM AddressContact WHERE AddressId = {userPersonalInfoId}"; using (IDbConnection db = new SqlConnection(connectionString)) { contact = db.QueryFirstOrDefault <AddressContactModel>(query); } return(contact); }
public Address GetBillingAddress(String email) { using (ISession session = SessionFactory.Create()) { UserPersonalInfoModel userPersonalInfoModel = RepositoriyFactory.GetRepo <IUserPersonalInfoRepositoriy>(session).GetUserPersonalInfo(email); CustomerUserModel customerUser = RepositoriyFactory.GetRepo <ICustomerUserRepository>(session).GetCustomerUser(userPersonalInfoModel.UserPersonalInfoId); CustomerModel customer = RepositoriyFactory.GetRepo <ICustomerRepository>(session).GetCustomer(customerUser.CustomerId); AddressModel billingAddress = RepositoriyFactory.GetRepo <IAddressRepositoriy>(session).GetBilllingAddress("CustomerId", customerUser.CustomerId); AddressModel dedicatedAddress = RepositoriyFactory.GetRepo <IAddressRepositoriy>(session).GetDedicatedAddress(customerUser.CustomerId); AddressModel address = (customer.IsThirdPartyBillingEnabled == true) ? dedicatedAddress : billingAddress; LocationModel location = RepositoriyFactory.GetRepo <ILocationRepository>(session).GetLocation(address.AddressId); AddressContactModel contact = RepositoriyFactory.GetRepo <IAddressContactRepositoriy>(session).GetContactPerson(address.AddressId); return(BillingAddressMapper.GetBillingAddress(location, contact, address)); } }
public static Address GetBillingAddress(LocationModel location, AddressContactModel contact, AddressModel address) { Address billingAddress = new Address(); billingAddress.AddressAccessorials = new List <Object>(); billingAddress.AddressId = address.AddressId; billingAddress.City = address.City; billingAddress.CommercialType = null; billingAddress.CompanyName = address.CompanyName; billingAddress.ContactPerson = new ContactPerson(); billingAddress.ContactPerson.AddressContactId = contact.AddressContactId; billingAddress.ContactPerson.Email = contact.Email; billingAddress.ContactPerson.Ext = contact.Ext; billingAddress.ContactPerson.FirstName = contact.FirstName; billingAddress.ContactPerson.isPrimary = contact.IsPrimary; billingAddress.ContactPerson.LastName = contact.LastName; billingAddress.ContactPerson.Name = contact.FirstName;//&& billingAddress.ContactPerson.Phone = contact.Phone; billingAddress.ContactPerson.Position = contact.Position; billingAddress.Country = AddressHelper.GetCountry(address.CountryCode); billingAddress.DeliveryFromTime = address.DeliveryFromTime; billingAddress.DeliveryInstructions = address.DeliveryInstructions; billingAddress.DeliveryToTime = address.DeliveryToTime; billingAddress.IsCanada = address.IsCanada; billingAddress.Lat = address.Lat; if (location != null) { billingAddress.Location = new Location(); billingAddress.Location.AddressId = location.AddressId; billingAddress.Location.IsDefault = false;//&& billingAddress.Location.Name = location.Name; } billingAddress.Long = address.Long; billingAddress.PickUpInstructions = address.PickUpInstructions; billingAddress.PostalCode = address.PostalCode; billingAddress.ShippingFromTime = address.ShippingFromTime; billingAddress.ShippingToTime = address.ShippingToTime; billingAddress.State = address.State; billingAddress.StateCode = address.StateCode; billingAddress.StreetLine1 = address.StreetLine1; billingAddress.StreetLine2 = address.StreetLine2; return(billingAddress); }