public void Initialize()
        {
            this._remoteProductService      = Substitute.For <RemoteProductService>("StockAllocation/Products");
            this._dsrStockAllocationService = Substitute.For <DsrStockAllocationService>();

            var connectivityService = Substitute.For <IConnectivityService>();

            connectivityService.HasConnection().Returns(true);
            Resolver.Instance.RegisterSingleton(connectivityService);

            this._viewModel = new ManageStockViewModel
            {
                RemoteProductService      = this._remoteProductService,
                DsrStockAllocationService = this._dsrStockAllocationService,
                DsrPhoneNumber            = "0711111111"
            };

            this._falseStatusDsrStockServerResponseObject = new ServerResponse <DsrStockServerResponseObject>
            {
                IsSuccessStatus = true,
                RawResponse     = this._falseStatusJson
            };

            this._successDsrStockServerResponseObject = new ServerResponse <DsrStockServerResponseObject>
            {
                IsSuccessStatus = true,
                RawResponse     = this._successJson
            };

            this._noPoductsDsrStockServerResponseObject = new ServerResponse <DsrStockServerResponseObject>
            {
                IsSuccessStatus = true,
                RawResponse     = this._noProductsJson
            };
        }
Пример #2
0
        public IActionResult EditStock(ManageStockViewModel manageStockViewModel, string radioButton, string amountToUpdate)
        {
            if (ModelState.IsValid)
            {
                BloodStock bloodStockToUpdate = context.BloodStock.Find(manageStockViewModel.Id);


                if (radioButton == "Increase")
                {
                    bloodStockToUpdate.Quantity = manageStockViewModel.Quantity + int.Parse(amountToUpdate);
                }
                else
                {
                    if (manageStockViewModel.Quantity < int.Parse(amountToUpdate))
                    {
                        ModelState.AddModelError("AmountToUpdate", "Please enter a quantity less than " + manageStockViewModel.Quantity + " units");
                        return(View(manageStockViewModel));
                    }
                    bloodStockToUpdate.Quantity = manageStockViewModel.Quantity - int.Parse(amountToUpdate);
                }

                context.BloodStock.Update(bloodStockToUpdate);
                context.SaveChanges();
                TempData["msg"] = "Blood Group: " + bloodStockToUpdate.BloodGroup + " updated to " + bloodStockToUpdate.Quantity + " units.";
                return(Redirect("/ManageStock"));
            }
            return(View(manageStockViewModel));
        }
Пример #3
0
        public IActionResult EditStock(string value)
        {
            BloodStock           bloodStock           = context.BloodStock.Find(int.Parse(value));
            ManageStockViewModel manageStockViewModel = new ManageStockViewModel(bloodStock);

            return(View(manageStockViewModel));
        }
        /// <summary>
        ///Created by Michael Takrama
        ///2017/03/02
        /// Parses the lots into a View Model for Datagrid
        /// </summary>
        private void ParseLotsIntoViewModel()
        {
            _productManager  = new ProductManager();
            _supplierManager = new SupplierManager();
            _locationManager = new LocationManager();

            try
            {
                _manageStockViewModels.Clear();
                foreach (var a in _productLotList)
                {
                    var manageStockViewModel = new ManageStockViewModel
                    {
                        ProductId         = a.ProductId,
                        ProductName       = _productManager.RetrieveProductById((int)a.ProductId).Name,
                        SupplierId        = a.SupplierId,
                        SupplierName      = _supplierManager.RetrieveSupplierBySupplierID((int)a.SupplierId).FarmName,
                        LocationDesc      = _locationManager.RetrieveLocationByID((int)a.LocationId).Description,
                        Quantity          = a.Quantity,
                        AvailableQuantity = a.AvailableQuantity,
                        ProductLotId      = a.ProductLotId
                    };

                    if (manageStockViewModel.AvailableQuantity != 0 || _checkBoxOverride)
                    {
                        _manageStockViewModels.Add(manageStockViewModel);
                    }
                }
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show("Catastrophic Error: " + ex.Message);
                }
            }
        }
Пример #5
0
 public StockList()
 {
     InitializeComponent();
     _ManageStockViewModel = new ManageStockViewModel();
     this.DataContext      = _ManageStockViewModel;
 }