none
How to fetch data from a database, calculate and output to UI RRS feed

  • Question

  •  

    My request is pretty easy to understand, I suppose. I have two tables in my database and I want to create a new DataTable which is populated with the results of the following equation for each cell. After the calculation I want to output the result table to the user.

    (expected - observed)/expected

    Now, in case I was unclear, a simple pseudo-example is the following:

    (Table1[1,1] - Table2[1,1])/Table1[1,1]

    What I've written until now, in the control file, is the following:

    [HttpPost]
            public ActionResult BO(Category editcategory)
            {   DataSet dsObserved = new DataSet();
                DataSet dsBaselines = new DataSet();
                
                var sharesTable = db.Shares.Select(s => new { s.valueSalesShares, s.volumeSalesShares,s.valueDistributionShares,s.volumeDistributionShares }).ToList();
                var baselineTable = db.Baselines.Select(b => new { b.valueSalesBaselines, b.volumeSalesBaselines, b.valueDistributionBaselines, b.volumeDistributionBaselines }).ToList();
                
                ViewBag.result = baselineTable;
                return View();            
            }


    Do you think that I want is plausible and if so, can you provide a solution or book which I can follow? Because, as I said before, I believe what I ask for is pretty easy to do.

    • Moved by CoolDadTx Monday, March 4, 2019 6:47 PM ASP.NET related
    Monday, March 4, 2019 3:17 PM

All replies

  • FYI.

    It's not called Viewbag View Controller. It's called Model View Controller.

    https://tech.trailmax.info/2013/12/asp-net-mvc-viewbag-is-bad/

    https://www.c-sharpcorner.com/UploadFile/56fb14/understanding-separation-of-concern-and-Asp-Net-mvc/

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/overview/understanding-models-views-and-controllers-cs

    http://trainitsolutions.com/2014/10/06/advantages-of-viewmodel-in-mvcmodel-view-controller-2/

    https://dzone.com/articles/reasons-move-datatables

    The MVC forum at ASP.NET forums someone there will point you to a tutorial.

    https://forums.asp.net/

    Monday, March 4, 2019 4:35 PM
  • Please post questions related to MVC in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, March 4, 2019 6:47 PM