public ActionResult ToSell(SalesAddViewModel model)
        {
            var product = _productService.GetById(model.ProductId);

            if (product.Stock > model.Quantity)
            {
                _saleProcessService.Create(new SalesProcess
                {
                    ProductId  = model.ProductId,
                    Quantity   = model.Quantity,
                    CustomerId = model.CustomerId,
                    EmployeeId = model.EmployeeId,
                    Total      = model.Total,
                    Price      = model.Price,
                    Date       = Convert.ToDateTime(DateTime.Now.ToShortDateString())
                });
                short quantity = Convert.ToInt16(model.Quantity);

                product.Stock = product.Stock - quantity;

                _productService.Update(product);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SalesAddView);
            vm = ViewModel as SalesAddViewModel;
            ActionBar.Hide();
            this.Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan);

            Button proceedButton = FindViewById <Button>(Resource.Id.btnProceed);

            proceedButton.Click += delegate
            {
                var progressDialog = ProgressDialog.Show(this, "Please wait...", "Transaction is being processed", true);
                new Thread(new ThreadStart(async delegate
                {
                    await vm.ProceedCommand();
                    RunOnUiThread(() => progressDialog.Dismiss());
                })).Start();
            };
        }