{"id":329018,"date":"2022-02-03T15:00:12","date_gmt":"2022-02-03T15:00:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329018"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329018","title":{"rendered":"<span>CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 Blazor, .Net 6.0 \u0438 Entity Framework Core<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/241\/85d\/b47\/24185db475d142904827a37c4d49dc43.png\" data-width=\"780\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Blazor, .Net 6.0 \u0438 Entity Framework Core \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 \u0431\u0430\u0437\u0435 Asp.Net Core.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Visual Studio 2022 \u0438 SQL Server 2014.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h3>\n<p>\u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u201c<strong>userdetails<\/strong>\u201d. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 SQL Server \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u201c<strong>userdetails<\/strong>\u201d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"sql\">CREATE TABLE [dbo].[userdetails](     [userid] [int] IDENTITY(1,1) NOT NULL,     [username] [nvarchar](100) NULL,     [address] [nvarchar](500) NULL,     [cellnumber] [nvarchar](50) NULL,     [emailid] [nvarchar](50) NULL,     CONSTRAINT [PK_userdetails] PRIMARY KEY CLUSTERED     (         [userid] ASC     ) )<\/code><\/pre>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Blazor<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Blazor WebAssembly \u0438 .Net 6.0. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Visual Studio 2022 \u0438 \u0441\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u044d\u0442\u043e\u0439 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p><strong>\u0428\u0430\u0433 1<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"404\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0b3\/6d4\/c40\/0b36d4c40356f09d82960533bb92c402.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0428\u0430\u0433 2<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"532\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/83d\/9e6\/5b6\/83d9e65b6b254c232c6abb967a8153d7.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0438\u043f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u201c<strong>Blazor WebAssembly App<\/strong>\u201d.<\/p>\n<p><strong>\u0428\u0430\u0433 3<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"534\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fbd\/3bc\/b63\/fbd3bcb63ba3b969da91e98f6e562bdd.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0428\u0430\u0433 4<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"531\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a96\/e8e\/124\/a96e8e1242d76c7f5e03abce92049cd4.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0442\u0438\u043f Framework\u2019\u0430 &#8212; .NET 6.0, \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u043a\u0438 &#8212; ASP.NET Core.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Blazor, \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043e\u043a \u0432 Solution Explorer \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ccf\/430\/1a2\/ccf4301a2672e8c264fc21808f3c4ba0.png\" data-width=\"295\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u0438\u043c 3 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u043b\u044e\u0448\u0435\u043d\u0430 \u201c<strong>BlazorApp<\/strong>\u201d.<\/p>\n<ul>\n<li>\n<p><strong>BlazorApp.Client<\/strong> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>BlazorApp.Server<\/strong> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u0435\u0431-API.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>BlazorApp.Shared<\/strong> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u0430\u043a \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u0438 \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u043d\u0430\u0436\u0430\u0432 F5, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"541\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab2\/ccf\/4b4\/ab2ccf4b44057f063a564e91bf73c26b.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 Nuget-\u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043f\u0443\u043d\u043a\u0442 \u043c\u0435\u043d\u044e \u201c<strong>Tools<\/strong>\u201d, \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>NuGet Package Manager<\/strong> > <strong>Package Manager Console<\/strong><\/p>\n<p>\u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b Entity Framework.<\/p>\n<p>=> Install-Package Microsoft.EntityFrameworkCore.SqlServer<\/p>\n<p>=> Install-Package Microsoft.EntityFrameworkCore.Tools<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Model, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 User.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Shared\u201d<\/strong> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u201c<strong>Models<\/strong>\u201d.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u043f\u0430\u043f\u043a\u0443 \u201cModels\u201d \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u201c<strong>User.cs<\/strong>\u201d.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>User.cs<\/strong>\u201d \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043a\u043e\u0434, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BlazorApp.Shared.Models {     public class User     {         public int Userid { get; set; }         public string Username { get; set; } = null!;         public string Address { get; set; } = null!;         public string Cellnumber { get; set; } = null!;         public string Emailid { get; set; } = null!;     } }<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u201c<strong>DatabaseContext.cs<\/strong>\u201d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Server<\/strong>\u201d \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 \u201c<strong>Models<\/strong>\u201d. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>DatabaseContext.cs<\/strong>\u201d \u0432 \u043f\u0430\u043f\u043a\u0443 \u201c<strong>Models<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Shared.Models; using Microsoft.EntityFrameworkCore; namespace BlazorApp.Server.Models {     public partial class DatabaseContext : DbContext     {         public DatabaseContext()         {         }         public DatabaseContext(DbContextOptions&lt;DatabaseContext> options)             : base(options)         {         }         public virtual DbSet&lt;User> Users { get; set; } = null!;         protected override void OnModelCreating(ModelBuilder modelBuilder)         {             modelBuilder.Entity&lt;User>(entity =>             {                 entity.ToTable(\"userdetails\");                 entity.Property(e => e.Userid).HasColumnName(\"Userid\");                 entity.Property(e => e.Username)                     .HasMaxLength(100)                     .IsUnicode(false);                 entity.Property(e => e.Address)                     .HasMaxLength(500)                     .IsUnicode(false);                 entity.Property(e => e.Cellnumber)                     .HasMaxLength(50)                     .IsUnicode(false);                 entity.Property(e => e.Emailid)                     .HasMaxLength(50)                     .IsUnicode(false);             });             OnModelCreatingPartial(modelBuilder);         }         partial void OnModelCreatingPartial(ModelBuilder modelBuilder);     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438 \u201c<strong>Interfaces<\/strong>\u201d \u0438 \u201c<strong>Services<\/strong>\u201d \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Server<\/strong>\u201d \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u0432\u0435 \u043d\u043e\u0432\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 \u201c<strong>Interfaces<\/strong>\u201d \u0438 \u201c<strong>Services<\/strong>\u201d.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u043f\u0430\u043f\u043a\u0443 \u201cInterfaces\u201d, \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u201c<strong>IUser.cs<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Shared.Models; namespace BlazorApp.Server.Interfaces {     public interface IUser     {         public List&lt;User> GetUserDetails();         public void AddUser(User user);         public void UpdateUserDetails(User user);         public User GetUserData(int id);         public void DeleteUser(int id);     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u201c<strong>UserManager.cs<\/strong>\u201d \u0432 \u043f\u0430\u043f\u043a\u0443 \u201c<strong>Services<\/strong>\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u201c<strong>IUser<\/strong>\u201d, \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Server.Interfaces; using BlazorApp.Server.Models; using BlazorApp.Shared.Models; using Microsoft.EntityFrameworkCore; namespace BlazorApp.Server.Services {     public class UserManager : IUser     {         readonly DatabaseContext _dbContext = new();         public UserManager(DatabaseContext dbContext)         {             _dbContext = dbContext;         }         \/\/\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435         public List&lt;User> GetUserDetails()         {             try             {                 return _dbContext.Users.ToList();             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         public void AddUser(User user)         {             try             {                 _dbContext.Users.Add(user);                 _dbContext.SaveChanges();             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         public void UpdateUserDetails(User user)         {             try             {                 _dbContext.Entry(user).State = EntityState.Modified;                 _dbContext.SaveChanges();             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435         public User GetUserData(int id)         {             try             {                 User? user = _dbContext.Users.Find(id);                 if (user != null)                 {                     return user;                 }                 else                 {                     throw new ArgumentNullException();                 }             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         public void DeleteUser(int id)         {             try             {                 User? user = _dbContext.Users.Find(id);                 if (user != null)                 {                     _dbContext.Users.Remove(user);                     _dbContext.SaveChanges();                 }                 else                 {                     throw new ArgumentNullException();                 }             }             catch             {                 throw;             }         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u201c<strong>DatabaseContext<\/strong>\u201d, \u201c<strong>IUser<\/strong>\u201d \u0438 \u201c<strong>UserManager<\/strong>\u201d \u0432 \u0444\u0430\u0439\u043b <strong>Program.cs <\/strong>\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u201c<strong>BlazorApp.Server<\/strong>\u201d.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>Program.cs<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Server.Interfaces; using BlazorApp.Server.Models; using BlazorApp.Server.Services; using Microsoft.AspNetCore.ResponseCompression; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \/\/\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c ConnectionStrings \u043a\u0430\u043a  \"DefaultConnection\" \u0432 \u0444\u0430\u0439\u043b appsetting.json builder.Services.AddDbContext&lt;DatabaseContext>     (options =>     options.UseSqlServer(builder.Configuration.GetConnectionString(\"DefaultConnection\"))); builder.Services.AddTransient&lt;IUser, UserManager>(); builder.Services.AddControllersWithViews(); builder.Services.AddRazorPages(); var app = builder.Build(); \/\/ Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) {     app.UseWebAssemblyDebugging(); } else {     app.UseExceptionHandler(\"\/Error\");    \/\/ \u0414\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 HSTS \u2014 30 \u0434\u043d\u0435\u0439. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e, \u0441\u043c. https:\/\/aka.ms\/aspnetcore-hsts.     app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.MapRazorPages(); app.MapControllers(); app.MapFallbackToFile(\"index.html\"); app.Run();<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0431-API \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u043e \u043f\u0430\u043f\u043a\u0435 \u201c<strong>BlazorApp.Server\/Controllers<\/strong>\u201d \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>Add<\/strong>\u201d, \u0437\u0430\u0442\u0435\u043c \u201c<strong>New Item<\/strong>\u201d. \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u201cAdd New Item\u201d. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>ASP.NET<\/strong>\u201d \u043d\u0430 \u043b\u0435\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>API Controller &#8212; Empty<\/strong>\u201d \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0438 \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u201c<strong>UserController.cs<\/strong>\u201d. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 Add, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>UserController.cs<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Server.Interfaces; using BlazorApp.Shared.Models; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace BlazorApp.Server.Controllers {     [Route(\"api\/[controller]\")]     [ApiController]     public class UserController : ControllerBase     {         private readonly IUser _IUser;         public UserController(IUser iUser)         {             _IUser = iUser;         }         [HttpGet]         public async Task&lt;List&lt;User>> Get()         {             return await Task.FromResult(_IUser.GetUserDetails());         }         [HttpGet(\"{id}\")]         public IActionResult Get(int id)         {             User user = _IUser.GetUserData(id);             if (user != null)             {                 return Ok(user);             }             return NotFound();         }         [HttpPost]         public void Post(User user)         {             _IUser.AddUser(user);         }         [HttpPut]         public void Put(User user)         {             _IUser.UpdateUserDetails(user);         }         [HttpDelete(\"{id}\")]         public IActionResult Delete(int id)         {             _IUser.DeleteUser(id);             return Ok();         }     } }<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Razor View \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0440\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Client<\/strong>\u201d. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u201c<strong>UserDetails.razor<\/strong>\u201d, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u201c<strong>AddUser.razor<\/strong>\u201d \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u201c<strong>DeleteUser.razor<\/strong>\u201d \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u043e \u043f\u0430\u043f\u043a\u0435 \u201c<strong>Pages<\/strong>\u201d \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u201c<strong>BlazorApp.Client<\/strong>\u201d \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>Add<\/strong>\u201d, \u0437\u0430\u0442\u0435\u043c \u201c<strong>New Item<\/strong>\u201d. \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u201c<strong>Add New Item<\/strong>\u201d. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>Web<\/strong>\u201d \u043d\u0430 \u043b\u0435\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>Razor Component<\/strong>\u201d \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0438 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043c\u044f \u201c<strong>UserDetails.razor<\/strong>\u201d. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0449\u0435 \u0434\u0432\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u201c<strong>AddUser.razor<\/strong>\u201d \u0438 \u201c<strong>DeleteUser.razor<\/strong>\u201d \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Client<\/strong>\u201d.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>UserDetails.razor<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">@page \"\/fetchuserdetails\" @using BlazorApp.Shared.Models @inject HttpClient Http &lt;h1>User Data&lt;\/h1> &lt;p>Blazor CRUD operation&lt;\/p> &lt;div class=\"row\">     &lt;div class=\"col-md-6\">         &lt;a href='\/user\/add' class=\"btn btn-primary\" role=\"button\">             &lt;i class=\"fas fa-user-plus\">&lt;\/i>             Add User         &lt;\/a>     &lt;\/div>     &lt;div class=\"input-group col\">         &lt;input type=\"text\" class=\"form-control\" placeholder=\"Search user by name\"                @bind=\"SearchString\" @bind:event=\"oninput\" @onkeyup=\"FilterUser\" \/>         @if (SearchString.Length > 0)         {             &lt;div class=\"input-group-append\">                 &lt;button class=\"btn btn-danger\" @onclick=\"ResetSearch\">                     &lt;i class=\"fas fa-times\">&lt;\/i>                 &lt;\/button>             &lt;\/div>         }     &lt;\/div> &lt;\/div> &lt;br \/> @if (userList == null) {     &lt;p>&lt;em>Loading...&lt;\/em>&lt;\/p> } else {     &lt;table class=\"table table-striped align-middle table-bordered\">         &lt;thead class=\"table-success\">             &lt;tr>                 &lt;th>ID&lt;\/th>                 &lt;th>Name&lt;\/th>                 &lt;th>Address&lt;\/th>                 &lt;th>Department&lt;\/th>                 &lt;th>Cell No&lt;\/th>                 &lt;th>E-mail&lt;\/th>             &lt;\/tr>         &lt;\/thead>         &lt;tbody>             @foreach (var user in userList)             {                 &lt;tr>                     &lt;td>@user.Userid&lt;\/td>                     &lt;td>@user.Username&lt;\/td>                     &lt;td>@user.Address&lt;\/td>                     &lt;td>@user.Cellnumber&lt;\/td>                     &lt;td>@user.Emailid&lt;\/td>                     &lt;td>                         &lt;a href='\/user\/edit\/@user.Userid' class=\"btn btn-outline-dark\" role=\"button\">                             Edit                         &lt;\/a>                         &lt;a href='\/user\/delete\/@user.Userid' class=\"btn btn-outline-danger\" role=\"button\">                             Delete                         &lt;\/a>                     &lt;\/td>                 &lt;\/tr>             }         &lt;\/tbody>      &lt;\/table> } @code {     protected List&lt;User> userList = new();     protected List&lt;User> searchUserData = new();     protected User user = new();     protected string SearchString { get; set; } = string.Empty;     protected override async Task OnInitializedAsync()     {         await GetUser();     }     protected async Task GetUser()     {         userList = await Http.GetFromJsonAsync&lt;List&lt;User>>(\"api\/User\");         searchUserData = userList;     }     protected void FilterUser()     {         if (!string.IsNullOrEmpty(SearchString))         {             userList = searchUserData                 .Where(x => x.Username.IndexOf(SearchString, StringComparison.OrdinalIgnoreCase) != -1)                 .ToList();         }         else         {             userList = searchUserData;         }     }     protected void DeleteConfirm(int userID)     {         user = userList.FirstOrDefault(x => x.Userid == userID);     }     public void ResetSearch()     {         SearchString = string.Empty;         userList = searchUserData;     } }<\/code><\/pre>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u201c<strong>AddUser.razor<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434, \u0433\u0434\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e \u043d\u0435\u043c \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"sql\">@page \"\/user\/add\" @page \"\/user\/edit\/{userId:int}\" @using BlazorApp.Shared.Models @inject HttpClient Http @inject NavigationManager NavigationManager &lt;h1>@Title User&lt;\/h1> &lt;hr \/> &lt;EditForm Model=\"@user\" OnValidSubmit=\"SaveUser\">     &lt;DataAnnotationsValidator \/>     &lt;div class=\"mb-3\">         &lt;label for=\"Name\" class=\"form-label\">Name&lt;\/label>         &lt;div class=\"col-md-4\">             &lt;InputText class=\"form-control\" @bind-Value=\"user.Username\" \/>         &lt;\/div>         &lt;ValidationMessage For=\"@(() => user.Username)\" \/>     &lt;\/div>     &lt;div class=\"mb-3\">         &lt;label for=\"Address\" class=\"form-label\">Address&lt;\/label>         &lt;div class=\"col-md-4\">             &lt;InputText class=\"form-control\" @bind-Value=\"user.Address\" \/>         &lt;\/div>         &lt;ValidationMessage For=\"@(() => user.Address)\" \/>     &lt;\/div>     &lt;div class=\"mb-3\">         &lt;label for=\"Cellnumber\" class=\"form-label\">Cell No&lt;\/label>         &lt;div class=\"col-md-4\">             &lt;InputText class=\"form-control\" @bind-Value=\"user.Cellnumber\" \/>         &lt;\/div>         &lt;ValidationMessage For=\"@(() => user.Cellnumber)\" \/>     &lt;\/div>     &lt;div class=\"mb-3\">         &lt;label for=\"Emailid\" class=\"form-label\">E-mail&lt;\/label>         &lt;div class=\"col-md-4\">             &lt;InputText class=\"form-control\" @bind-Value=\"user.Emailid\" \/>         &lt;\/div>         &lt;ValidationMessage For=\"@(() => user.Emailid)\" \/>     &lt;\/div>     &lt;div class=\"form-group\">         &lt;button type=\"submit\" class=\"btn btn-primary\">Save&lt;\/button>         &lt;button class=\"btn btn-light\" @onclick=\"Cancel\">Cancel&lt;\/button>     &lt;\/div> &lt;\/EditForm> @code {     [Parameter]     public int userId { get; set; }     protected string Title = \"Add\";     protected User user = new();     protected override async Task OnParametersSetAsync()     {         if (userId != 0)         {             Title = \"Edit\";             user = await Http.GetFromJsonAsync&lt;User>(\"api\/User\/\" + userId);         }     }     protected async Task SaveUser()     {         if (user.Userid != 0)         {             await Http.PutAsJsonAsync(\"api\/User\", user);         }         else         {             await Http.PostAsJsonAsync(\"api\/User\", user);         }         Cancel();     }     public void Cancel()     {         NavigationManager.NavigateTo(\"\/fetchuserdetails\");     } }<\/code><\/pre>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u201cDeleteUser.razor\u201d \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"sql\">@page \"\/user\/delete\/{userId:int}\" @using BlazorApp.Shared.Models @inject HttpClient Http @inject NavigationManager NavigationManager &lt;h2>Delete User&lt;\/h2> &lt;br \/> &lt;div class=\"form-group\">     &lt;h4>Do you want to delete this user?&lt;\/h4>     &lt;table class=\"table\">         &lt;tbody>             &lt;tr>                 &lt;td>Name&lt;\/td>                 &lt;td>@user.Username&lt;\/td>             &lt;\/tr>             &lt;tr>                 &lt;td>Address&lt;\/td>                 &lt;td>@user.Address&lt;\/td>             &lt;\/tr>             &lt;tr>                 &lt;td>Cell No&lt;\/td>                 &lt;td>@user.Cellnumber&lt;\/td>             &lt;\/tr>             &lt;tr>                 &lt;td>E-mail&lt;\/td>                 &lt;td>@user.Emailid&lt;\/td>             &lt;\/tr>         &lt;\/tbody>     &lt;\/table> &lt;\/div> &lt;div class=\"form-group\">     &lt;input type=\"submit\" value=\"Delete\" @onclick=\"(async () => await RemoveUser(user.Userid))\" class=\"btn btn-danger\" \/>     &lt;input type=\"submit\" value=\"Cancel\" @onclick=\"(() => Cancel())\" class=\"btn btn-warning\" \/> &lt;\/div> @code {     [Parameter]     public int userId { get; set; }     User user = new User();     protected override async Task OnInitializedAsync()     {         user = await Http.GetFromJsonAsync&lt;User>(\"\/api\/User\/\" + Convert.ToInt32(userId));     }     protected async Task RemoveUser(int userID)     {         await Http.DeleteAsync(\"api\/User\/\" + userID);         NavigationManager.NavigateTo(\"\/fetchuserdetails\");     }     void Cancel()     {         NavigationManager.NavigateTo(\"\/fetchuserdetails\");     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u201cUser Details\u201d \u0432 \u043c\u0435\u043d\u044e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b<strong><em> <\/em><\/strong>\u201c<strong><em>BlazorApp.Client\/Shared\/ NavMenu.razor<\/em><\/strong><em>\u201d \u0438<\/em> \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">&lt;div class=\"top-row ps-3 navbar navbar-dark\">     &lt;div class=\"container-fluid\">         &lt;a class=\"navbar-brand\" href=\"\">BlazorApp&lt;\/a>         &lt;button title=\"Navigation menu\" class=\"navbar-toggler\" @onclick=\"ToggleNavMenu\">             &lt;span class=\"navbar-toggler-icon\">&lt;\/span>         &lt;\/button>     &lt;\/div> &lt;\/div> &lt;div class=\"@NavMenuCssClass\" @onclick=\"ToggleNavMenu\">     &lt;nav class=\"flex-column\">         &lt;div class=\"nav-item px-3\">             &lt;NavLink class=\"nav-link\" href=\"\" Match=\"NavLinkMatch.All\">                 &lt;span class=\"oi oi-home\" aria-hidden=\"true\">&lt;\/span> Home             &lt;\/NavLink>         &lt;\/div>         &lt;div class=\"nav-item px-3\">             &lt;NavLink class=\"nav-link\" href=\"counter\">                 &lt;span class=\"oi oi-plus\" aria-hidden=\"true\">&lt;\/span> Counter             &lt;\/NavLink>         &lt;\/div>         &lt;div class=\"nav-item px-3\">             &lt;NavLink class=\"nav-link\" href=\"fetchdata\">                 &lt;span class=\"oi oi-list-rich\" aria-hidden=\"true\">&lt;\/span> Fetch data             &lt;\/NavLink>         &lt;\/div>         &lt;div class=\"nav-item px-3\">             &lt;NavLink class=\"nav-link\" href=\"fetchuserdetails\">                 &lt;span class=\"oi oi-list-rich\" aria-hidden=\"true\">&lt;\/span> User Details             &lt;\/NavLink>         &lt;\/div>     &lt;\/nav>  &lt;\/div> @code {     private bool collapseNavMenu = true;     private string? NavMenuCssClass => collapseNavMenu ? \"collapse\" : null;     private void ToggleNavMenu()     {         collapseNavMenu = !collapseNavMenu;     } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u201c<strong>User Details<\/strong>\u201d \u043f\u043e\u0434 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u201cFetch Data\u201d \u0441 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"427\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b0\/912\/644\/4b0912644417cb1ae939e8c603109174.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043a\u043b\u0438\u043a\u0430\u0435\u043c <em>\u201c<\/em><strong>User Details<\/strong><em>\u201d<\/em> \u0432 \u043c\u0435\u043d\u044e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u043e\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 <em>\u201c<\/em><strong>User Details<\/strong><em>\u201d<\/em> \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"426\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a9a\/e4a\/2da\/a9ae4a2da625ad19a321500beecb441d.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u201cUser Details\u201d \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u201cAdd User\u201d. \u041d\u0430\u0436\u0430\u0432 \u0435\u0435, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u201cAdd User\u201d, \u0433\u0434\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"541\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/62c\/124\/da6\/62c124da65f3ae87d2393e749eb0ed05.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u201cEdit\u201d \u0438\u043b\u0438 \u201cDelete\u201d \u044d\u0442\u043e\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435), \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u0433\u0434\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"542\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/894\/4d5\/471\/8944d5471b7312285c1360503ec0d778.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"544\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d93\/c48\/571\/d93c485710d9ca7b603ffc53e5aa426c.png\" data-width=\"800\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f ASP.NET Core \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Blazor Entity Framework \u0438 .NET 6.0, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438 CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/p>\n<hr\/>\n<blockquote>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0431\u043e\u0440\u0430 \u0443\u0447\u0430\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043a\u0443\u0440\u0441\u0430 \u00abC# ASP.NET Core \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u00bb. \u0421\u043a\u043e\u0440\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0443\u0440\u0441\u0430 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 demo-\u0443\u0440\u043e\u043a \u043d\u0430 \u0442\u0435\u043c\u0443 <strong>\u00ab\u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 API: SignalR Core\u00bb<\/strong>. \u041d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e API: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 SignalR \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0430\u0442\u0430. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u2014 <a href=\"https:\/\/otus.pw\/bg97\/\">\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c.<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/649585\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/649585\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Blazor, .Net 6.0 \u0438 Entity Framework Core \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430 \u0431\u0430\u0437\u0435 Asp.Net Core.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Visual Studio 2022 \u0438 SQL Server 2014.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h3>\n<p>\u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u201c<strong>userdetails<\/strong>\u201d. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 SQL Server \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u201c<strong>userdetails<\/strong>\u201d, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"sql\">CREATE TABLE [dbo].[userdetails](     [userid] [int] IDENTITY(1,1) NOT NULL,     [username] [nvarchar](100) NULL,     [address] [nvarchar](500) NULL,     [cellnumber] [nvarchar](50) NULL,     [emailid] [nvarchar](50) NULL,     CONSTRAINT [PK_userdetails] PRIMARY KEY CLUSTERED     (         [userid] ASC     ) )<\/code><\/pre>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Blazor<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Blazor WebAssembly \u0438 .Net 6.0. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Visual Studio 2022 \u0438 \u0441\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u044d\u0442\u043e\u0439 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p><strong>\u0428\u0430\u0433 1<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u0428\u0430\u0433 2<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0438\u043f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u201c<strong>Blazor WebAssembly App<\/strong>\u201d.<\/p>\n<p><strong>\u0428\u0430\u0433 3<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u0428\u0430\u0433 4<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0442\u0438\u043f Framework\u2019\u0430 &#8212; .NET 6.0, \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u043a\u0438 &#8212; ASP.NET Core.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Blazor, \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u043f\u043e\u043a \u0432 Solution Explorer \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u0438\u043c 3 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u043b\u044e\u0448\u0435\u043d\u0430 \u201c<strong>BlazorApp<\/strong>\u201d.<\/p>\n<ul>\n<li>\n<p><strong>BlazorApp.Client<\/strong> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>BlazorApp.Server<\/strong> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432\u0435\u0431-API.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><strong>BlazorApp.Shared<\/strong> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u0430\u043a \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0442\u0430\u043a \u0438 \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u043d\u0430\u0436\u0430\u0432 F5, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 Nuget-\u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043f\u0443\u043d\u043a\u0442 \u043c\u0435\u043d\u044e \u201c<strong>Tools<\/strong>\u201d, \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <strong>NuGet Package Manager<\/strong> > <strong>Package Manager Console<\/strong><\/p>\n<p>\u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b Entity Framework.<\/p>\n<p>=> Install-Package Microsoft.EntityFrameworkCore.SqlServer<\/p>\n<p>=> Install-Package Microsoft.EntityFrameworkCore.Tools<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Model, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 User.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Shared\u201d<\/strong> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u201c<strong>Models<\/strong>\u201d.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u043f\u0430\u043f\u043a\u0443 \u201cModels\u201d \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u201c<strong>User.cs<\/strong>\u201d.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>User.cs<\/strong>\u201d \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043a\u043e\u0434, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BlazorApp.Shared.Models {     public class User     {         public int Userid { get; set; }         public string Username { get; set; } = null!;         public string Address { get; set; } = null!;         public string Cellnumber { get; set; } = null!;         public string Emailid { get; set; } = null!;     } }<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u201c<strong>DatabaseContext.cs<\/strong>\u201d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Server<\/strong>\u201d \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 \u201c<strong>Models<\/strong>\u201d. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>DatabaseContext.cs<\/strong>\u201d \u0432 \u043f\u0430\u043f\u043a\u0443 \u201c<strong>Models<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Shared.Models; using Microsoft.EntityFrameworkCore; namespace BlazorApp.Server.Models {     public partial class DatabaseContext : DbContext     {         public DatabaseContext()         {         }         public DatabaseContext(DbContextOptions&lt;DatabaseContext> options)             : base(options)         {         }         public virtual DbSet&lt;User> Users { get; set; } = null!;         protected override void OnModelCreating(ModelBuilder modelBuilder)         {             modelBuilder.Entity&lt;User>(entity =>             {                 entity.ToTable(\"userdetails\");                 entity.Property(e => e.Userid).HasColumnName(\"Userid\");                 entity.Property(e => e.Username)                     .HasMaxLength(100)                     .IsUnicode(false);                 entity.Property(e => e.Address)                     .HasMaxLength(500)                     .IsUnicode(false);                 entity.Property(e => e.Cellnumber)                     .HasMaxLength(50)                     .IsUnicode(false);                 entity.Property(e => e.Emailid)                     .HasMaxLength(50)                     .IsUnicode(false);             });             OnModelCreatingPartial(modelBuilder);         }         partial void OnModelCreatingPartial(ModelBuilder modelBuilder);     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438 \u201c<strong>Interfaces<\/strong>\u201d \u0438 \u201c<strong>Services<\/strong>\u201d \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u201c<strong>BlazorApp.Server<\/strong>\u201d \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u0432\u0435 \u043d\u043e\u0432\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 \u201c<strong>Interfaces<\/strong>\u201d \u0438 \u201c<strong>Services<\/strong>\u201d.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u043f\u0430\u043f\u043a\u0443 \u201cInterfaces\u201d, \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u201c<strong>IUser.cs<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Shared.Models; namespace BlazorApp.Server.Interfaces {     public interface IUser     {         public List&lt;User> GetUserDetails();         public void AddUser(User user);         public void UpdateUserDetails(User user);         public User GetUserData(int id);         public void DeleteUser(int id);     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u201c<strong>UserManager.cs<\/strong>\u201d \u0432 \u043f\u0430\u043f\u043a\u0443 \u201c<strong>Services<\/strong>\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u201c<strong>IUser<\/strong>\u201d, \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Server.Interfaces; using BlazorApp.Server.Models; using BlazorApp.Shared.Models; using Microsoft.EntityFrameworkCore; namespace BlazorApp.Server.Services {     public class UserManager : IUser     {         readonly DatabaseContext _dbContext = new();         public UserManager(DatabaseContext dbContext)         {             _dbContext = dbContext;         }         \/\/\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435         public List&lt;User> GetUserDetails()         {             try             {                 return _dbContext.Users.ToList();             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         public void AddUser(User user)         {             try             {                 _dbContext.Users.Add(user);                 _dbContext.SaveChanges();             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         public void UpdateUserDetails(User user)         {             try             {                 _dbContext.Entry(user).State = EntityState.Modified;                 _dbContext.SaveChanges();             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435         public User GetUserData(int id)         {             try             {                 User? user = _dbContext.Users.Find(id);                 if (user != null)                 {                     return user;                 }                 else                 {                     throw new ArgumentNullException();                 }             }             catch             {                 throw;             }         }         \/\/\u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         public void DeleteUser(int id)         {             try             {                 User? user = _dbContext.Users.Find(id);                 if (user != null)                 {                     _dbContext.Users.Remove(user);                     _dbContext.SaveChanges();                 }                 else                 {                     throw new ArgumentNullException();                 }             }             catch             {                 throw;             }         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u201c<strong>DatabaseContext<\/strong>\u201d, \u201c<strong>IUser<\/strong>\u201d \u0438 \u201c<strong>UserManager<\/strong>\u201d \u0432 \u0444\u0430\u0439\u043b <strong>Program.cs <\/strong>\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u201c<strong>BlazorApp.Server<\/strong>\u201d.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>Program.cs<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Server.Interfaces; using BlazorApp.Server.Models; using BlazorApp.Server.Services; using Microsoft.AspNetCore.ResponseCompression; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \/\/\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c ConnectionStrings \u043a\u0430\u043a  \"DefaultConnection\" \u0432 \u0444\u0430\u0439\u043b appsetting.json builder.Services.AddDbContext&lt;DatabaseContext>     (options =>     options.UseSqlServer(builder.Configuration.GetConnectionString(\"DefaultConnection\"))); builder.Services.AddTransient&lt;IUser, UserManager>(); builder.Services.AddControllersWithViews(); builder.Services.AddRazorPages(); var app = builder.Build(); \/\/ Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) {     app.UseWebAssemblyDebugging(); } else {     app.UseExceptionHandler(\"\/Error\");    \/\/ \u0414\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 HSTS \u2014 30 \u0434\u043d\u0435\u0439. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e, \u0441\u043c. https:\/\/aka.ms\/aspnetcore-hsts.     app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.MapRazorPages(); app.MapControllers(); app.MapFallbackToFile(\"index.html\"); app.Run();<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0431-API \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043f\u043e \u043f\u0430\u043f\u043a\u0435 \u201c<strong>BlazorApp.Server\/Controllers<\/strong>\u201d \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>Add<\/strong>\u201d, \u0437\u0430\u0442\u0435\u043c \u201c<strong>New Item<\/strong>\u201d. \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u201cAdd New Item\u201d. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>ASP.NET<\/strong>\u201d \u043d\u0430 \u043b\u0435\u0432\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201c<strong>API Controller &#8212; Empty<\/strong>\u201d \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0438 \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u201c<strong>UserController.cs<\/strong>\u201d. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 Add, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440.<\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u201c<strong>UserController.cs<\/strong>\u201d \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"sql\">using BlazorApp.Server.Interfaces; using BlazorApp.Shared.Models; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace BlazorApp.Server.Controllers {     [Route(\"api\/[controller]\")]     [ApiController]     public class UserController : ControllerBase     {         private readonly IUser _IUser;         public UserController(IUser iUser)         {             _IUser = iUser;         }         [HttpGet]         public async Task&lt;List&lt;User>> Get()         {             return await<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-329018","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329018"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329018\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}