Beispiel #1
0
        public async override Task <ActionResult <StockItemUpdate> > HandleAsync(StockItemUpdate request)
        {
            var result = await _stockManager.Update(request);

            if (result == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(result));
            }
        }
        public IActionResult Update(Stock stock)
        {
            DynamicParameters dynamicParameters = new DynamicParameters();

            dynamicParameters.Add("@ID", stock.ID);
            var data = _stockManager.Get("select * from Stocks where ID = @ID", dynamicParameters);

            data.Name            = stock.Name;
            data.Amount          = stock.Amount;
            data.CurrencyCode    = stock.CurrencyCode;
            data.GTIPNo          = stock.GTIPNo;
            data.StockCategoryID = stock.StockCategoryID;
            data.StockCode       = stock.StockCode;
            return(Ok(_stockManager.Update(data, "update Stocks set [Name] = @Name, [Amount] = @Amount, [CurrencyCode] = @CurrencyCode, " +
                                           "[GTIPNo] = @GTIPNo, [StockCategoryID] = @StockCategoryID, [StockCode] = @StockCode " +
                                           "where ID = @ID")));
        }
Beispiel #3
0
        public IActionResult Edit(int id, [Bind("Id,Quantity,Unit,ProductId,ProductName")] Stock stock)
        {
            if (id != stock.Id)
            {
                return(NotFound());
            }

            PopulateDropdownList(stock.ProductId);

            if (ModelState.IsValid)
            {
                bool isUpdated = _stockManager.Update(stock);
                if (isUpdated)
                {
                    var stocks = _stockManager.GetAll();
                    ViewBag.SuccessMessage = "Stock Updated Successfully!";
                    return(View("Index", stocks));
                }
            }
            return(View(stock));
        }