public async void OnNavigatedTo(object argument, NavigationType navigationMode)
        {
            var           customerRaw = argument as string;
            CustomerModel customer;

            if (argument is CustomerType)
            {
                customer = CustomerModelFactory.FromType((CustomerType)argument);
            }
            else if (customerRaw != null)
            {
                customer =
                    await
                    customerRaw.FromJsonAsync <CustomerModel>(new JsonSerializerSettings
                {
                    TypeNameHandling = TypeNameHandling.Objects
                });
            }
            else
            {
                throw new ArgumentOutOfRangeException("argument");
            }

            var person = customer as PersonModel;

            if (person != null && person.CompanyID.HasValue)
            {
                person.Company = await this.customerService.Find <CompanyModel>(person.CompanyID.Value);

                customer = person;
            }

            // Retrieve invoices for the given customer
            if (customer.ID != default(int))
            {
                var invoices = await this.invoiceService.All(customer.ID);

                customer.Invoices = new ObservableCollection <InvoiceModel>(invoices);
            }

            this.CustomerDataViewModel =
                this.container.Resolve <CustomerDataViewModel>(new ParameterOverride("customer", customer));
            this.InvoiceDataViewModel =
                this.container.Resolve <InvoiceDataViewModel>(new ParameterOverrides
            {
                { "invoices", customer.Invoices },
                { "customerID", customer.ID }
            });
            this.RaisePropertyChanged(() => this.CustomerDataViewModel);
            this.RaisePropertyChanged(() => this.InvoiceDataViewModel);
        }
Example #2
0
 public void Test_InvalidType()
 {
     CustomerModelFactory.FromType(CustomerType.None);
 }
Example #3
0
        public void Test_CompanyType()
        {
            var model = CustomerModelFactory.FromType(CustomerType.Company);

            Assert.IsInstanceOfType(model, typeof(CompanyModel));
        }
Example #4
0
        public void Test_PersonType()
        {
            var model = CustomerModelFactory.FromType(CustomerType.Person);

            Assert.IsInstanceOfType(model, typeof(PersonModel));
        }
 public void PrepareShortModel()
 {
     var customerModelFactory = new CustomerModelFactory(_customerService.Object);
     var model = customerModelFactory.PrepareCustomerShortModel(1);
 }