private IReadOnlyList <ICustomerModel> ParseGetCustomersCustomers(
            JsonElement parent,
            string field)
        {
            if (!parent.TryGetProperty(field, out JsonElement obj))
            {
                return(null);
            }

            if (obj.ValueKind == JsonValueKind.Null)
            {
                return(null);
            }

            int objLength = obj.GetArrayLength();
            var list      = new ICustomerModel[objLength];

            for (int objIndex = 0; objIndex < objLength; objIndex++)
            {
                JsonElement element = obj[objIndex];
                list[objIndex] = new CustomerModel
                                 (
                    DeserializeInt(element, "id"),
                    DeserializeNullableString(element, "name"),
                    DeserializeNullableString(element, "location")
                                 );
            }

            return(list);
        }
Esempio n. 2
0
 public void ShipItem(ICustomerModel customer)
 {
     if (HasOrderBeenCompleted == false)
     {
         Console.WriteLine($"Simulating shipping { Title } to { customer.FirstName } in { customer.City }");
         HasOrderBeenCompleted = true;
     }
 }
 public void ShipItem(ICustomerModel customer)
 {
     if (HasOrderBeenCompleted == false)
     {
         Console.WriteLine($"Added the {Title} course to {customer.FirstName}'s account.");
         HasOrderBeenCompleted = true;
     }
 }
Esempio n. 4
0
 static Presenter()
 {
     UserModel     = new UserModel();
     ProductModel  = new ProductModel();
     SupplierModel = new SupplierModel();
     OrderModel    = new OrderModel();
     DetailModel   = new DetailModel();
     CustomerModel = new CustomerModel();
 }
 public OrdersViewModel(ICustomerModel customer)
     : base(customer.CompanyName)
 {
     _customer = customer;
     if (IsInDesignMode)
     {
         // Code runs in Blend --> create design time data.
     }
     else
     {
         // Code runs "for real": Connect to service, etc...
     }
 }
Esempio n. 6
0
        public void ShipItem(ICustomerModel customer)
        {
            if (HasOrderBeenCompleted == false)
            {
                Console.WriteLine($"Simulating e-mailing { Title } to { customer.EmailAddress }");
                TotalDownloadsLeft -= 1;

                if (TotalDownloadsLeft < 1)
                {
                    HasOrderBeenCompleted = true;
                    TotalDownloadsLeft    = 0;
                }
            }
        }
Esempio n. 7
0
 public CustomerDetailsViewModel(string customerID)
 {
     _customer = ApplicationServices.Instance
                 .NorthwindManager.GetCustomerByID(customerID);
     Name = Strings.CustomerDetailsDisplayName;
     ((INotifyPropertyChanged)_customer).PropertyChanged
           += CustomerDetailsViewModel_PropertyChanged;
     Orders =
         ApplicationServices.Instance
         .NorthwindManager.GetOrders(
             Customer.CustomerID);
     UpdateCommandViewModel = new CommandViewModel(
         Strings.UpdateCommandName,
         new RelayCommand(UpdateCommand_Execute,
                          UpdateCommand_CanExecute));
 }
Esempio n. 8
0
        static void Main(string[] args)
        {
            List <IProductModel> cart     = AddSampleData();
            ICustomerModel       customer = GetCustomer();

            foreach (IProductModel prod in cart)
            {
                prod.ShipItem(customer);

                if (prod is IDigitalProductModel digital)
                {
                    Console.WriteLine($"For the {digital.Title} you have {digital.TotalDownloadsLeft} downloads left");
                }
            }

            Console.ReadLine();
        }
Esempio n. 9
0
 public void Put([FromBody] ICustomerModel value)
 {
     _customerService.Update(value);
 }
Esempio n. 10
0
 public void Post([FromBody] ICustomerModel value)
 {
     _customerService.Add(value);
 }
Esempio n. 11
0
        public bool Update(ICustomerModel model)
        {
            var customer = _mapper.Map <Customer>(model);

            return(_repo.Update(customer));
        }
Esempio n. 12
0
        public ICustomerModel Add(ICustomerModel model)
        {
            var customer = _mapper.Map <Customer>(model);

            return(_mapper.Map <CustomerModel>(_repo.Add(customer)));
        }
 public CustomerViewModel(ICustomerModel model)
 {
     _model = model;
     ((INotifyPropertyChanged)_model).PropertyChanged
         += CustomerViewModelPropertyChanged;
 }