Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

retrieve and store the number of records

$
0
0

Hi,

I use asp net core mvc (2.0)

I have two tables:
"Tasklist" and "Tasks"

CREATE TABLE [dbo].[TaskList] (
    [ID]          INT            IDENTITY (1, 1) NOT NULL,
    [Aufgabe]     NVARCHAR (50) NULL,
    [Status]      INT            NOT NULL,
    [zusatz]      NVARCHAR (50) NULL,
    [UserId]      NVARCHAR (450) NOT NULL,
    CONSTRAINT [PK_TaskList] PRIMARY KEY CLUSTERED ([ID] ASC)
);

CREATE TABLE [dbo].[Tasks] (
    [ID]  INT IDENTITY (1, 1) NOT NULL,
    [TaskList]  INT NULL,
    [done]  BIT NOT NULL,
    [Aufgabe]  NVARCHAR (150) NULL,
    [Start]  DATETIME NULL,
    [Ende]  DATETIME NULL,
    CONSTRAINT [PK_Tasks] PRIMARY KEY CLUSTERED ([ID] ASC),
    CONSTRAINT [FK_Tasks_TaskList] FOREIGN KEY ([TaskList]) REFERENCES [dbo].[TaskList] ([ID])
);

In "TaskList" there is the Task description. 
The individual tasks are in the table "Tasks"

When I display the entries from "TaskList", I would like to display the number of associated tasks from "Tasks", which are done and which not.
The calculated percentage number I would then write in TaskList.Status. 

Enclosed my TaskList Controller

        // GET: TaskList
        public async Task<IActionResult> Index(string sortOrder)
        {

            var fg = User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier).Value;
            var x412Context = _context.TaskList;
            var sorting = from m in x412Context
                          where m.UserId == fg
                          select m;

            switch (sortOrder)
            {
                default:
                    sorting = sorting.OrderBy(m => m.Status);
                    break;
            }

            return View(await sorting.ToListAsync());

        }


Can someone tell me how I can do this?
Thank you Paul


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>