From 52e38d2ec46d7ad38d19f89bd60b9320f942a0c3 Mon Sep 17 00:00:00 2001 From: neroduckale Date: Wed, 3 Jan 2024 01:55:32 +0500 Subject: [PATCH] =?UTF-8?q?=D1=8F=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BC?= =?UTF-8?q?=D0=BD=D1=8E=20=D1=87=D1=82=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB,=20=D0=BD=D0=BE=20=D0=BD=D0=B0=D1=87=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20/users.=20TODO:?= =?UTF-8?q?=20=D0=90=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nrdkwebsite/Pages/index.cshtml | 3 +-- nrdkwebsite/Pages/layout.cshtml | 5 +++-- nrdkwebsite/Pages/users.cshtml | 19 +++++++++++++------ nrdkwebsite/Program.cs | 5 ++--- nrdkwebsite/User.cs | 11 +++++++++++ nrdkwebsite/wwwroot/js/site.js | 8 +++++--- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/nrdkwebsite/Pages/index.cshtml b/nrdkwebsite/Pages/index.cshtml index e4de078..0f7b1f1 100644 --- a/nrdkwebsite/Pages/index.cshtml +++ b/nrdkwebsite/Pages/index.cshtml @@ -1,10 +1,9 @@ @page @model IndexModel @{ - ViewData["Title"] = "Home page"; + ViewData["Title"] = "home page"; } -

Привет, это сайт neroduckale

Мой никнейм читается по разному - неродакля, неродукель, неродакале, но одно в нем остается неизменным - неро.

спасибо мактайлорс за помощь с созданием сайта. version: 0.3 diff --git a/nrdkwebsite/Pages/layout.cshtml b/nrdkwebsite/Pages/layout.cshtml index 69ce572..9a8829f 100644 --- a/nrdkwebsite/Pages/layout.cshtml +++ b/nrdkwebsite/Pages/layout.cshtml @@ -9,9 +9,10 @@ - @* *@ + - + @* *@ + diff --git a/nrdkwebsite/Pages/users.cshtml b/nrdkwebsite/Pages/users.cshtml index 3ddda27..5c27c68 100644 --- a/nrdkwebsite/Pages/users.cshtml +++ b/nrdkwebsite/Pages/users.cshtml @@ -1,16 +1,23 @@ @page -@using System.Collections @model Users - - - - -
текст заголовкатекст заголовка
данныеданные
+Всего в таблице записей: +
+ + + +
АйдиНикнеймМасть
Loading...Loading...Loading...
+
\ No newline at end of file diff --git a/nrdkwebsite/Program.cs b/nrdkwebsite/Program.cs index 214ab99..860cee6 100644 --- a/nrdkwebsite/Program.cs +++ b/nrdkwebsite/Program.cs @@ -45,9 +45,8 @@ app.MapDelete("/api/users/{id:int}", async (int id, DatabaseHandler db) => { await db.SaveChangesAsync(); return Results.Json(user); }); //WORKS -app.MapPost("/api/users", async (User user, DatabaseHandler db)=> -{ - user.id = db.users.Count() + 1; +app.MapPost("/api/users", async (NewUser newuser, DatabaseHandler db) => { + User user = new User(newuser.nickname, db.users.Count() + 1, newuser.mast); await db.users.AddAsync(user); await db.SaveChangesAsync(); return user; diff --git a/nrdkwebsite/User.cs b/nrdkwebsite/User.cs index 7354bb5..5c22109 100644 --- a/nrdkwebsite/User.cs +++ b/nrdkwebsite/User.cs @@ -12,4 +12,15 @@ public class User this.id = id; this.mast = mast; } +} +public class NewUser +{ + public string nickname { get; set; } + public string mast { get; set; } + + public NewUser(string nickname, string mast) + { + this.nickname = nickname; + this.mast = mast; + } } \ No newline at end of file diff --git a/nrdkwebsite/wwwroot/js/site.js b/nrdkwebsite/wwwroot/js/site.js index 2249b06..7257803 100644 --- a/nrdkwebsite/wwwroot/js/site.js +++ b/nrdkwebsite/wwwroot/js/site.js @@ -9,9 +9,10 @@ async function getUsers() { if (response.ok === true) { // получаем данные const users = await response.json(); - const rows = document.querySelector("tbody"); - // добавляем полученные элементы в таблицу - users.forEach(user => rows.append(row(user))); + const table = document.querySelector("#users"); + const count = document.querySelector("#count") + count.outerHTML = "1"; + document.querySelector("#loading").destroy(); } } // Получение одного пользователя @@ -33,3 +34,4 @@ async function getUser(id) { } } // Добавление пользователя +await getUsers(); \ No newline at end of file