Example #1
0
        public static CustomerAddressRepository GetCustomerAddressRepository(IUnitOfWork unitOfWork)
        {
            var repository = new CustomerAddressRepository();

            repository.UnitOfWork = unitOfWork;
            return(repository);
        }
Example #2
0
        public ActionResult Index(PersonalInformationPage currentPage, PersonalSettingsForm personalSettingsForm)
        {
            PersonalInformationViewModel model = new PersonalInformationViewModel(currentPage);
            var currentMarket = ServiceLocator.Current.GetInstance <ICurrentMarket>();

            model.PersonalSettingsForm = personalSettingsForm;


            ContactRepository contactRepository = new ContactRepository();

            contactRepository.Save(model.PersonalSettingsForm.ContactInformation);

            CustomerAddressRepository addressRepository = new CustomerAddressRepository();

            personalSettingsForm.BillingAddress.CheckAndSetCountryCode();
            personalSettingsForm.BillingAddress.IsPreferredBillingAddress = true;
            addressRepository.Save(personalSettingsForm.BillingAddress);

            personalSettingsForm.ShippingAddress.CheckAndSetCountryCode();
            personalSettingsForm.ShippingAddress.IsPreferredShippingAddress = true;
            addressRepository.Save(personalSettingsForm.ShippingAddress);

            if (Request.IsAjaxRequest())
            {
                return(PartialView(model));
            }


            //Save data
            return(View(model));
        }
        /// <summary>
        /// Delete an Address for the given customer
        /// </summary>
        /// <param name="param">Service call params <see cref="DeleteAddressParam"/></param>
        /// <returns>
        /// The status representing a possible cause of errors.
        /// </returns>
        public virtual async Task <DeleteAddressStatusViewModel> DeleteAddressAsync(DeleteAddressParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (param.AddressId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.AddressId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

            if (!await EnsureAddressBelongsToCustomer(param.CustomerId, param.Scope, param.AddressId).ConfigureAwait(false))
            {
                return(null);
            }

            await CustomerAddressRepository.DeleteAddressAsync(param.AddressId).ConfigureAwait(false);

            return(new DeleteAddressStatusViewModel());
        }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="shoppingService">Shopping service</param>
 /// <param name="addressRepository">Address repository</param>
 /// <param name="paymentMethodRepository">Payment method repository</param>
 /// <param name="shippingOptionRepository">Shipping option repository</param>
 /// <param name="countryRepository">Country repository</param>
 public CheckoutService(IShoppingService shoppingService, CustomerAddressRepository addressRepository, PaymentMethodRepository paymentMethodRepository, ShippingOptionRepository shippingOptionRepository, CountryRepository countryRepository)
 {
     mShoppingService          = shoppingService;
     mPaymentMethodRepository  = paymentMethodRepository;
     mShippingOptionRepository = shippingOptionRepository;
     mCountryRepository        = countryRepository;
     mAddressRepository        = addressRepository;
 }
 public CheckoutController(CustomerAddressRepository customerAddressRepository, IContentRepository contentRepository, ICurrentMarket currentMarket,
                           LocalizationService localizationService)
 {
     _customerAddressRepository = customerAddressRepository;
     _contactRepository         = new ContactRepository();
     _contentRepository         = contentRepository;
     _currentMarket             = currentMarket;
     _localizationService       = localizationService;
 }
 public PropertiesController(IEzbobWorkplaceContext context,
                             CustomerRepository customerRepository,
                             CustomerAddressRepository customerAddressRepository, ServiceClient serviceClient)
 {
     this.customerRepository        = customerRepository;
     this.customerAddressRepository = customerAddressRepository;
     this.serviceClient             = serviceClient;
     this.context = context;
 }
Example #7
0
        /// <summary>
        /// Gets the <see cref="AddressListViewModel"/> to display a list of addresses in MyAddresses Form or Form result
        /// </summary>
        /// <param name="param">Builder params <see cref="GetAddressListViewModelParam"/></param>
        /// <returns></returns>
        public virtual async Task <AddressListViewModel> GetAddressListViewModelAsync(GetAddressListViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("param.CultureInfo");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("param.Scope");
            }
            if (string.IsNullOrWhiteSpace(param.AddAddressUrl))
            {
                throw new ArgumentException("param.AddAddressUrl");
            }
            if (string.IsNullOrWhiteSpace(param.EditAddressBaseUrl))
            {
                throw new ArgumentException("param.EditAddressBaseUrl");
            }
            if (string.IsNullOrWhiteSpace(param.CountryCode))
            {
                throw new ArgumentException("param.CountryCode");
            }

            var customer = await CustomerRepository.GetCustomerByIdAsync(new GetCustomerByIdParam
            {
                CultureInfo = param.CultureInfo,
                CustomerId  = param.CustomerId,
                Scope       = param.Scope
            }).ConfigureAwait(false);

            IList <Address> addresses = customer.Addresses;

            if (addresses == null)
            {
                addresses = await CustomerAddressRepository.GetCustomerAddressesAsync(
                    customer.Id, param.Scope).ConfigureAwait(false);
            }

            var regions = await CountryService.RetrieveRegionsAsync(new RetrieveCountryParam
            {
                IsoCode     = param.CountryCode,
                CultureInfo = param.CultureInfo,
            }).ConfigureAwait(false);

            var viewModel = GetAddressListViewModel(param, customer, addresses, regions);

            return(viewModel);
        }
Example #8
0
        public IHttpActionResult DeleteCustomerAddress([FromBody] Cust_Addr customeraddress)
        {
            var customeraddressRepo = new CustomerAddressRepository();
            var result = customeraddressRepo.DeleteCustomerAddress(customeraddress);

            if (result <= 0)
            {
                return(Ok("Error occurred while Deleting the Customer address"));
            }
            return(Ok("Deleted Customer address"));
        }
Example #9
0
        public IHttpActionResult UpdateCustomerAddressStatus([FromBody] Cust_Addr customeraddress)
        {
            var custaddressRepo = new CustomerAddressRepository();
            var result          = custaddressRepo.UpdateCustomerAddressStatus(customeraddress);

            if (result <= 0)
            {
                return(Ok("Error occurred while updating the Customer Address status"));
            }
            return(Ok("Customer Address Status updated"));
        }
Example #10
0
        public IHttpActionResult GetCustomerAddress([FromBody] Cust_Addr customeraddress)
        {
            var custaddressRepo    = new CustomerAddressRepository();
            var getcustomeraddress = custaddressRepo.GetCustomerAddress(customeraddress);

            if (getcustomeraddress == null)
            {
                return(NotFound());
            }
            return(Ok(getcustomeraddress));
        }
Example #11
0
        // GET: api/CustomerAddress
        public IHttpActionResult GetAllCustomerAddrresses()
        {
            var custaddressRepo     = new CustomerAddressRepository();
            var customeraddressList = custaddressRepo.GetAllCustomerAddresses();

            if (customeraddressList == null || customeraddressList.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(customeraddressList));
        }
        public PersonalSettingsForm()
        {
            ContactRepository contactRepository = new ContactRepository();
            ContactInformation = contactRepository.Get();

            CustomerAddressRepository addressRepository = new CustomerAddressRepository();
            ShippingAddress = addressRepository.GetAll().FirstOrDefault(a => a.IsPreferredShippingAddress);
            BillingAddress = addressRepository.GetAll().FirstOrDefault(a => a.IsPreferredBillingAddress);

            SetDefaultName(ShippingAddress, ContactInformation);
            SetDefaultName(BillingAddress, ContactInformation);
        }
Example #13
0
 public CrossCheckController(
     CustomerRepository customerRepository,
     DirectorRepository directorRepository,
     CustomerAddressRepository customerAddressRepository,
     ISession oSession, IWorkplaceContext context)
 {
     this.m_oServiceClient           = new ServiceClient();
     this._customerRepository        = customerRepository;
     this._customerAddressRepository = customerAddressRepository;
     this._directorRepository        = directorRepository;
     this.m_oSession = oSession;
     this._context   = context;
 }         // constructor
Example #14
0
        public UnitOfWork()
        {
            _context.Configuration.LazyLoadingEnabled = true;

            Brand           = new BrandRepository(_context);
            Category        = new CategoryRepository(_context);
            Customer        = new CustomerRepository(_context);
            CustomerAddress = new CustomerAddressRepository(_context);
            File            = new FileRepository(_context);
            Product         = new ProductRepository(_context);
            Promotion       = new PromotionRepository(_context);
            ProductParent   = new ProductParentRepository(_context);
            Provider        = new ProviderRepository(_context);
        }
        public PersonalSettingsForm()
        {
            ContactRepository contactRepository = new ContactRepository();

            ContactInformation = contactRepository.Get();

            CustomerAddressRepository addressRepository = new CustomerAddressRepository();

            ShippingAddress = addressRepository.GetAll().FirstOrDefault(a => a.IsPreferredShippingAddress);
            BillingAddress  = addressRepository.GetAll().FirstOrDefault(a => a.IsPreferredBillingAddress);

            SetDefaultName(ShippingAddress, ContactInformation);
            SetDefaultName(BillingAddress, ContactInformation);
        }
        protected virtual async Task UpdateAddressAsync(Guid customerId, Guid otherAddressId, Guid addressId)
        {
            if (otherAddressId == addressId)
            {
                return;
            }

            var otherAddress = await AddressRepository.GetAddressByIdAsync(otherAddressId).ConfigureAwait(false);

            if (otherAddress != null && otherAddress.IsPreferredShipping)
            {
                otherAddress.IsPreferredShipping = false;
                await CustomerAddressRepository.UpdateAddressAsync(customerId, otherAddress).ConfigureAwait(false);
            }
        }
Example #17
0
        /// <summary>
        /// Create a new Address for the given customer
        /// </summary>
        /// <param name="createAddressParam">Service call params <see cref="CreateAddressParam"/></param>
        /// <returns>
        /// The created Address and a status representing a possible cause of errors.
        /// </returns>
        public virtual async Task <EditAddressViewModel> CreateAddressAsync(CreateAddressParam createAddressParam)
        {
            if (createAddressParam == null)
            {
                throw new ArgumentNullException("createAddressParam");
            }
            if (createAddressParam.CultureInfo == null)
            {
                throw new ArgumentException("createAddressParam.CultureInfo");
            }
            if (createAddressParam.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("createAddressParam.CustomerId");
            }
            if (createAddressParam.EditAddress == null)
            {
                throw new ArgumentException("createAddressParam.EditAddress");
            }
            if (string.IsNullOrWhiteSpace(createAddressParam.Scope))
            {
                throw new ArgumentException("createAddressParam.Scope");
            }

            var createdAddress = await CustomerAddressRepository
                                 .CreateAddressAsync(createAddressParam.CustomerId,
                                                     ConvertToAddress(new Address(), createAddressParam.EditAddress), createAddressParam.Scope)
                                 .ConfigureAwait(false);

            if (createAddressParam.EditAddress.IsPreferredShipping || createAddressParam.EditAddress.IsPreferredBilling)
            {
                await SetDefaultAddressAsync(new SetDefaultAddressParam
                {
                    AddressId  = createdAddress.Id,
                    CustomerId = createAddressParam.CustomerId,
                    Scope      = createAddressParam.Scope
                }).ConfigureAwait(false);
            }

            return(await GetEditAddressViewModel(new GetEditAddressViewModelParam
            {
                Address = createdAddress,
                Status = MyAccountStatus.Success,
                ReturnUrl = createAddressParam.ReturnUrl,
                IsUpdating = false,
                CultureInfo = createAddressParam.CultureInfo
            }).ConfigureAwait(false));
        }
Example #18
0
 public CheckoutController(CustomerAddressRepository customerAddressRepository, IContentRepository contentRepository,
                           ICurrentMarket currentMarket, ICustomerFactory customerFactory,
                           LocalizationService localizationService,
                           IWarehouseInventoryService warehouseInventory,
                           IWarehouseRepository warehouseRepository,
                           PaymentRegistry paymentRegistry)
 {
     _customerAddressRepository = customerAddressRepository;
     _contactRepository         = new ContactRepository();
     _contentRepository         = contentRepository;
     _currentMarket             = currentMarket;
     _localizationService       = localizationService;
     _customerFactory           = customerFactory;
     _warehouseInventory        = warehouseInventory;
     _warehouseRepository       = warehouseRepository;
     _paymentRegistry           = paymentRegistry;
 }
        /// <summary>
        /// Gets the <see cref="AddressListViewModel"/> to display a list of addresses in MyAddresses Form or Form result
        /// </summary>
        /// <param name="param">Builder params <see cref="GetAddressListViewModelParam"/></param>
        /// <returns></returns>
        public virtual async Task <AddressListViewModel> GetAddressListViewModelAsync(GetAddressListViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CountryCode))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CountryCode)), nameof(param));
            }

            var customer = await CustomerRepository.GetCustomerByIdAsync(new GetCustomerByIdParam
            {
                CultureInfo      = param.CultureInfo,
                CustomerId       = param.CustomerId,
                Scope            = param.Scope,
                IncludeAddresses = true,
            }).ConfigureAwait(false);

            IList <Address> addresses = customer.Addresses ?? await CustomerAddressRepository.GetCustomerAddressesAsync(customer.Id, param.Scope).ConfigureAwait(false);

            var regions = await CountryService.RetrieveRegionsAsync(new RetrieveCountryParam
            {
                IsoCode     = param.CountryCode,
                CultureInfo = param.CultureInfo,
            }).ConfigureAwait(false);

            var viewModel = GetAddressListViewModel(param, customer, addresses, regions);

            return(viewModel);
        }
        /// <summary>
        /// Get Default Address for given customer
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <AddressListItemViewModel> GetDefaultAddressViewModelAsync(GetAddressesForCustomerParam param)
        {
            var addresses = await CustomerAddressRepository.GetCustomerAddressesAsync(
                param.CustomerId, param.Scope).ConfigureAwait(false);

            if (addresses == null)
            {
                return(null);
            }

            var addressVm      = new AddressListItemViewModel();
            var defaultAddress = addresses.Find(a => a.IsPreferredShipping);

            if (defaultAddress != null)
            {
                addressVm = ViewModelMapper.MapTo <AddressListItemViewModel>(defaultAddress, param.CultureInfo);
            }

            return(addressVm);
        }
        /// <summary>
        /// Set default Address for the given customer
        /// </summary>
        /// <param name="param">Service call params <see cref="SetDefaultAddressParam"/></param>
        /// <returns>
        /// The status representing a possible cause of errors.
        /// </returns>
        public virtual async Task <SetDefaultAddressStatusViewModel> SetDefaultAddressAsync(SetDefaultAddressParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (param.AddressId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.AddressId)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

            var address = await AddressRepository.GetAddressByIdAsync(param.AddressId).ConfigureAwait(false);

            if (address == null)
            {
                return(null);
            }

            if (!await EnsureAddressBelongsToCustomer(param.CustomerId, param.Scope, address.Id).ConfigureAwait(false))
            {
                return(null);
            }

            address.IsPreferredShipping = true;
            address.IsPreferredBilling  = true;

            await CustomerAddressRepository.UpdateAddressAsync(param.CustomerId, address).ConfigureAwait(false);

            return(new SetDefaultAddressStatusViewModel());
        }
 public void SetUp()
 {
     _container = new AutoMocker();
     _container.Use(new Mock <IOvertureClient>(MockBehavior.Strict));
     _customerRepository = _container.CreateInstance <CustomerAddressRepository>();
 }
        /// <summary>
        /// Update an Address for the given customer
        /// </summary>
        /// <param name="editAddressParam">Service call params <see cref="EditAddressParam"/></param>
        /// <returns>
        /// The created Address and a status representing a possible cause of errors.
        /// </returns>
        public virtual async Task <EditAddressViewModel> UpdateAddressAsync(EditAddressParam editAddressParam)
        {
            if (editAddressParam == null)
            {
                throw new ArgumentNullException(nameof(editAddressParam));
            }
            if (editAddressParam.EditAddress == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(editAddressParam.EditAddress)), nameof(editAddressParam));
            }
            if (editAddressParam.AddressId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(editAddressParam.AddressId)), nameof(editAddressParam));
            }
            if (editAddressParam.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(editAddressParam.CustomerId)), nameof(editAddressParam));
            }
            if (editAddressParam.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(editAddressParam.CultureInfo)), nameof(editAddressParam));
            }
            if (string.IsNullOrWhiteSpace(editAddressParam.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(editAddressParam.Scope)), nameof(editAddressParam));
            }

            var baseAddress = await AddressRepository.GetAddressByIdAsync(editAddressParam.AddressId).ConfigureAwait(false);

            if (baseAddress == null)
            {
                return(null);
            }

            if (!await EnsureAddressBelongsToCustomer(editAddressParam.CustomerId, editAddressParam.Scope, baseAddress.Id).ConfigureAwait(false))
            {
                return(null);
            }

            var updatedAddress = await CustomerAddressRepository
                                 .UpdateAddressAsync(editAddressParam.CustomerId,
                                                     ConvertToAddress(baseAddress, editAddressParam.EditAddress))
                                 .ConfigureAwait(false);

            if (editAddressParam.EditAddress.IsPreferredShipping || editAddressParam.EditAddress.IsPreferredBilling)
            {
                await SetDefaultAddressAsync(new SetDefaultAddressParam
                {
                    AddressId  = editAddressParam.AddressId,
                    CustomerId = editAddressParam.CustomerId,
                    Scope      = editAddressParam.Scope
                }).ConfigureAwait(false);
            }

            //Update recurring carts with this address Id
            await RecurringOrderCartsViewService.UpdateRecurringOrderCartsAddressesAsync(new Cart.Parameters.UpdateRecurringOrderCartsAddressesParam
            {
                BaseUrl     = "Empty", //Dont need but can't allow empty
                CultureInfo = editAddressParam.CultureInfo,
                CustomerId  = editAddressParam.CustomerId,
                ScopeId     = editAddressParam.Scope,
                AddressId   = updatedAddress.Id,
            }).ConfigureAwait(false);

            return(await GetEditAddressViewModel(new GetEditAddressViewModelParam
            {
                Address = updatedAddress,
                Status = MyAccountStatus.Success,
                ReturnUrl = editAddressParam.ReturnUrl,
                IsUpdating = false,
                CultureInfo = editAddressParam.CultureInfo
            }).ConfigureAwait(false));
        }