Beispiel #1
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            // TODO - Make this async.

            Description = Discount.Description;

            var model = DiscountService.GetDiscountModel(Discount.Id);

            foreach (var product in ProductService.GetProducts())
            {
                var discountProduct = model.Products.Where(o => o.ProductId == product.Id).FirstOrDefault();
                DiscountProducts.Add(new DiscountProductViewModel {
                    Product = product, DiscountProduct = discountProduct ?? new DiscountProduct {
                        DiscountId = Discount.Id, ProductId = product.Id
                    }
                });
            }

            foreach (var customer in CustomerService.GetAllCustomers())
            {
                var discountCustomer = model.Customers.Where(o => o.CustomerId == customer.Id).FirstOrDefault();
                DiscountCustomers.Add(new DiscountCustomerViewModel {
                    Customer = customer, DiscountCustomer = discountCustomer ?? new DiscountCustomer {
                        DiscountId = Discount.Id, CustomerId = customer.Id
                    }, Selected = discountCustomer != null
                });
            }
        }
Beispiel #2
0
        public void Save()
        {
            var model = DiscountService.GetDiscountModel(Discount.Id);

            model.Discount.Description = Description;
            model.Products             = new List <DiscountProduct>(DiscountProducts.Where(o => o.Discount > 0.0m).Select(o => o.DiscountProduct));
            model.Customers            = new List <DiscountCustomer>(DiscountCustomers.Where(o => o.Selected).Select(o => o.DiscountCustomer));

            DiscountService.UpdateDiscountModel(model);

            Close();
        }
Beispiel #3
0
        public void Save()
        {
            var model = new DiscountModel
            {
                Discount = new Discount {
                    Description = Description
                },
                Products  = new List <DiscountProduct>(DiscountProducts.Where(o => o.Discount > 0.0m).Select(o => o.DiscountProduct)),
                Customers = new List <DiscountCustomer>(DiscountCustomers.Where(o => o.Selected).Select(o => o.DiscountCustomer))
            };

            DiscountService.InsertDiscountModel(model);

            Close();
        }
Beispiel #4
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            // TODO - Make this async.

            foreach (var product in ProductService.GetProducts())
            {
                DiscountProducts.Add(new DiscountProductViewModel {
                    Product = product, DiscountProduct = new DiscountProduct {
                        ProductId = product.Id
                    }, Discount = 0.0m
                });
            }

            foreach (var customer in CustomerService.GetAllCustomers())
            {
                DiscountCustomers.Add(new DiscountCustomerViewModel {
                    Customer = customer, DiscountCustomer = new DiscountCustomer {
                        CustomerId = customer.Id
                    }, Selected = false
                });
            }
        }