private Collection <MemberAddressCL> fetchMembers(Collection <MemberCL> members) { Collection <MemberAddressCL> memberWithAddress = new Collection <MemberAddressCL>(); foreach (MemberCL item in members) { AddressCL addressCL = addressBLL.getAddressById(item.addressId); AddressLocationCL cityCL = addressBLL.getCityById(addressCL.cityId); if (addressCL.addressTypeId == 0) { memberWithAddress.Add(new MemberAddressCL { id = item.id, name = item.name, password = item.password, mobNo = item.mobNo, isGuest = item.isGuest.ToString(), isDelete = item.isDeleted.ToString(), email = item.email, gender = item.gender ? "Male" : "Female", shippingAddress = addressCL.addressLine1 + ", " + addressCL.addressLine2 + ", " + addressCL.addressLine3 + ", " + cityCL.cityName + ", " + cityCL.stateName + ", " + cityCL.countryName, }); } else if (addressCL.addressTypeId == 1) { memberWithAddress.Add(new MemberAddressCL { id = item.id, name = item.name, password = item.password, mobNo = item.mobNo, isGuest = item.isGuest.ToString(), isDelete = item.isDeleted.ToString(), email = item.email, gender = item.gender ? "Male" : "Female", billingAddress = addressCL.addressLine1 + ", " + addressCL.addressLine2 + ", " + addressCL.addressLine3 + ", " + cityCL.cityName + ", " + cityCL.stateName + ", " + cityCL.countryName, }); } else if (addressCL.addressTypeId == 2) { memberWithAddress.Add(new MemberAddressCL { id = item.id, name = item.name, password = item.password, mobNo = item.mobNo, isGuest = item.isGuest.ToString(), isDelete = item.isDeleted.ToString(), email = item.email, gender = item.gender ? "Male" : "Female", permanentAddress = addressCL.addressLine1 + ", " + addressCL.addressLine2 + ", " + addressCL.addressLine3 + ", " + cityCL.cityName + ", " + cityCL.stateName + ", " + cityCL.countryName, }); } } return(memberWithAddress); }
/// <summary> /// Gets City, State & Country by Inputting City id. /// </summary> /// <param name="cityId">City Id for fetching All Location.</param> /// <returns>Address containing city, state & Country with Id.</returns> public AddressLocationCL getCityById(int cityId) { City query = (from x in dbcontext.Cities where x.Id == cityId select x).FirstOrDefault(); AddressLocationCL cityCL = new AddressLocationCL() { id = query.Id, stateId = query.StateId, countryId = query.State.CountryId, cityName = query.Name, stateName = query.State.Name, countryName = query.State.Country.Name }; return(cityCL); }