示例#1
0
        public IActionResult AddProductResult(AddProductViewModel userProduct)
        {
            var productViewModel = _inventoryService.AddProduct(userProduct);

            if (!ModelState.IsValid)
            {
                return(View("Error", new ErrorViewModel
                {
                    ErrorMessage = "Error product was not added correctly"
                }));
            }
            else
            {
                return(View("GetAllStoreProducts", productViewModel));
            }
        }
示例#2
0
        private void Save()
        {
            // TODO: Checking and validations

            try {
                if (SelectedProduct.ProductId != 0)
                {
                    _inventoryService.UpdateProduct(SelectedProduct);
                }
                else
                {
                    _inventoryService.AddProduct(SelectedProduct);
                }
                ShowMessage("Successfully Save Product!",
                            MahApps.Metro.Controls.Dialogs.MessageDialogStyle.Affirmative);
                IsAddEditMode = false;
                Initialize();
            }
            catch {
                ShowMessage("Error in saving Product!");
            }
        }