Example #1
0
        public IActionResult GetStocks()
        {
            var tableModel = new DataTablesAjaxRequestModel(Request);
            var model      = new StockViewModel();
            var data       = model.GetStocks(tableModel);

            return(Json(data));
        }
Example #2
0
        public IActionResult AddOrEdit(int id, StockUpdateModel model)
        {
            var viewModel = new StockViewModel();

            if (ModelState.IsValid)
            {
                //Add
                if (id == 0)
                {
                    model.AddStock();
                }
                //Update
                else
                {
                    model.UpdateStock(id);
                }
                return(Json(new { isValid = true, html = Helper <StockController> .RenderRazorViewToString(this, "_ViewAll", viewModel.GetStocks()) }));
            }
            return(Json(new { isValid = false, html = Helper <StockController> .RenderRazorViewToString(this, "AddOrEdit", model) }));
        }
Example #3
0
        public IActionResult DeleteConfirmed(int id)
        {
            var model     = new StockUpdateModel();
            var viewModel = new StockViewModel();

            model.Delete(id);
            return(Json(new { html = Helper <StockController> .RenderRazorViewToString(this, "_ViewAll", viewModel.GetStocks()) }));
        }
Example #4
0
        public IActionResult Index()
        {
            var model = new StockViewModel();

            return(View(model.GetStocks()));
        }