Example #1
0
        protected override async void Save()
        {
            var exist = Repository.Get(p => p.UPC == UPC).Count() > 0;

            if (exist)
            {
                await Dialoger.ShowMessageAsync(this, "Inventory", $"Product already exist with UPC:[{UPC}]",
                                                MessageDialogStyle.Affirmative, OkCancelMessageSettings);

                return;
            }

            var product = new P.Product()
            {
                UPC           = UPC,
                Name          = Name,
                Quantity      = Quantity,
                PurchasePrice = PurchasePrice,
                SalePrice     = SalePrice
            };

            Repository.Add(product);
            Repository.Save();
            UPC = Name = string.Empty;

            EA.GetEvent <ProductAddEvent>().Publish(product);
        }
Example #2
0
        protected virtual void GetProduct()
        {
            if (string.IsNullOrWhiteSpace(UPC) || UPC.Length < 7)
            {
                return;
            }

            var product = Repository.Get(p => p.UPC == UPC).FirstOrDefault();

            if (product == null)
            {
                Dialoger.ShowMessageAsync(this, "Product", $"No Product found for UPC:[{UPC}]", MahApps.Metro.Controls.Dialogs.MessageDialogStyle.Affirmative, OkCancelMessageSettings);
            }
            else
            {
                var productVM = new P.Product()
                {
                    Id            = product.Id,
                    Name          = product.Name,
                    PurchasePrice = product.PurchasePrice,
                    SalePrice     = product.SalePrice,
                    Quantity      = 0, ///Becasue the ListableViewModel will take care of quantity
                    UPC           = product.UPC
                };

                EA.GetEvent <PurchaseAddEvent>().Publish(productVM);
            }
        }
        protected override void Delete()
        {
            Quantity = Quantity - 1;

            if (Quantity > 0)
            {
                return;
            }

            var product = new P.Product()
            {
                UPC = UPC,
            };

            EA.GetEvent <PurchaseRemoveEvent>().Publish(product);
        }