예제 #1
0
        protected async Task HandleValidSubmit()
        {
            Product.CategoryId = int.Parse(CategoryId);

            if (Product.ProductId == 0)
            {
                var product = await ProductDataService.Add(Product);

                if (product != null)
                {
                    StatusClass = "alert-success";
                    Message     = "New category added successfully.";
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new category. Please try again.";
                }
            }
            else
            {
                await ProductDataService.Update(Product);

                StatusClass = "alert-success";
                Message     = "Category updated successfully.";
            }
        }
예제 #2
0
        private void AddProductData()
        {
            Product product = new Product()
            {
                Id          = new Guid(),
                Name        = mName.Text,
                BarcodeId   = mBarcode.Text,
                CategoryId  = new Guid(),
                AddedUserId = LoginPageActivity.StaticUserClass.ID.ToString()
            };

            mNewProductId = product.Id;

            new Thread(new ThreadStart(delegate
            {
                var isProductAdded = mProductDataService.Add(product);
                if (isProductAdded)
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Product Added", ToastLength.Long).Show());
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed to add, please check again form's field", ToastLength.Long).Show());
                }
            })).Start();
        }
예제 #3
0
        static void Main(string[] args)
        {
            try
            {
                var cs      = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString;
                var service = new ProductDataService(cs);

                for (int i = 0; i < 10; i++)
                {
                    var product = new ProductDTO();
                    product.Id   = i;
                    product.Name = String.Format("Product_{0}", i);

                    service.Add(product);
                    Console.WriteLine("Product {0} added", i);
                }

                Console.WriteLine("Get all products");

                var products = service.GetAll();

                foreach (var product in products)
                {
                    Console.WriteLine("Product '{0}' is retrieved", product.Name);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        protected async Task HandleValidSubmit()
        {
            var response = await ProductDataService.Add(Product);

            if (response.Errors.Any())
            {
                ShowError = true;
                Errors    = response.Errors;
            }
            else
            {
                ShowDialog = false;
                await CloseEventCallback.InvokeAsync(true);

                StateHasChanged();
            }
        }
예제 #5
0
        private void AddProductData()
        {
            mProduct.Name       = mName.Text;
            mProduct.BarcodeId  = mBarcode.Text;
            mProduct.CategoryId = mCategory.Id;

            new Thread(new ThreadStart(delegate
            {
                var isProductAdded = mProductDataService.Add(mProduct.ToModel());
                if (isProductAdded)
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Product Added", ToastLength.Long).Show());
                }
                else
                {
                    RunOnUiThread(() => Toast.MakeText(this, "Failed to add, please check again form's field", ToastLength.Long).Show());
                }
            })).Start();
        }
예제 #6
0
 /// <summary>
 /// Adds the specified entity.
 /// </summary>
 /// <param name="pr">The Product entity.</param>
 public override Product Add(Product pr)
 {
     _productDataService.Add(pr);
     return(pr);
 }
        public bool AddProduct(ProductModel product)
        {
            ProductDataService oPService = new ProductDataService();

            return(oPService.Add(product));
        }