Commit d5d4ce2d authored by TTrueBenji's avatar TTrueBenji

Перейти на Postgres.

***
- Подключил Postgres
Блиин, мне надо бежаааать
***
parent b9baac3d
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using PhoneStore.Models;
using PhoneStore.ViewModels;
using Order = PhoneStore.Enums.Order;
namespace PhoneStore.Controllers
{
public class UsersController : Controller
{
private readonly MobileContext _db;
public UsersController(MobileContext db)
{
_db = db;
}
[HttpGet]
public IActionResult Index(
string filteringCriterionByName,
int page = 1,
Order order = Order.NameAsc)
{
int pageSize = 2;
IQueryable<User> users = _db.Users.AsQueryable();
if (!string.IsNullOrEmpty(filteringCriterionByName))
users = users.Where(u => u.Name.Contains(filteringCriterionByName));
int count = users.Count();
users = _db
.Users
.OrderBy(u => u.Name)
.Skip((page - 1) * pageSize)
.Take(pageSize);
ViewBag.NameSort = order == Order.NameAsc ? Order.NameDesc : Order.NameAsc;
ViewBag.AgeSort = order == Order.AgeAsc ? Order.AgeDesc : Order.AgeAsc;
switch (order)
{
case Order.AgeDesc:
users = users.OrderByDescending(u => u.Age);
break;
case Order.AgeAsc:
users = users.OrderBy(u => u.Age);
break;
case Order.NameDesc:
users = users.OrderByDescending(u => u.Name);
break;
default:
users = users.OrderBy(u => u.Name);
break;
}
UsersViewModel model = new UsersViewModel
{
Filter = filteringCriterionByName,
Users = users.ToArray(),
PageViewModel = new PageViewModel(page, count, pageSize )
};
return View(model);
}
}
}
\ No newline at end of file
namespace PhoneStore.Enums
{
public enum Order
{
NameAsc,
NameDesc,
AgeAsc,
AgeDesc
}
}
\ No newline at end of file
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PhoneStore.Models;
namespace PhoneStore.Migrations
{
[DbContext(typeof(MobileContext))]
[Migration("20220622133702_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.17");
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Baskets");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Address")
.HasColumnType("TEXT");
b.Property<string>("ContactPhone")
.HasColumnType("TEXT");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Orders");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Company")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<decimal>("Price")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Phones");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PhoneStore.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Phones",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
Company = table.Column<string>(type: "TEXT", nullable: true),
Price = table.Column<decimal>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Phones", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Baskets",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PhoneId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Baskets", x => x.Id);
table.ForeignKey(
name: "FK_Baskets_Phones_PhoneId",
column: x => x.PhoneId,
principalTable: "Phones",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
UserName = table.Column<string>(type: "TEXT", nullable: true),
ContactPhone = table.Column<string>(type: "TEXT", nullable: true),
Address = table.Column<string>(type: "TEXT", nullable: true),
PhoneId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Phones_PhoneId",
column: x => x.PhoneId,
principalTable: "Phones",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Baskets_PhoneId",
table: "Baskets",
column: "PhoneId");
migrationBuilder.CreateIndex(
name: "IX_Orders_PhoneId",
table: "Orders",
column: "PhoneId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Baskets");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Phones");
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PhoneStore.Models;
namespace PhoneStore.Migrations
{
[DbContext(typeof(MobileContext))]
[Migration("20220630102229_BrandEntity")]
partial class BrandEntity
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.17");
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Baskets");
});
modelBuilder.Entity("PhoneStore.Models.Brand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Brands");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Address")
.HasColumnType("TEXT");
b.Property<string>("ContactPhone")
.HasColumnType("TEXT");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Orders");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("BrandId")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<decimal>("Price")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("BrandId");
b.ToTable("Phones");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.HasOne("PhoneStore.Models.Brand", "Brand")
.WithMany()
.HasForeignKey("BrandId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Brand");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PhoneStore.Migrations
{
public partial class BrandEntity : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Company",
table: "Phones");
migrationBuilder.AddColumn<int>(
name: "BrandId",
table: "Phones",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Brands",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Brands", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Phones_BrandId",
table: "Phones",
column: "BrandId");
migrationBuilder.AddForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones",
column: "BrandId",
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones");
migrationBuilder.DropTable(
name: "Brands");
migrationBuilder.DropIndex(
name: "IX_Phones_BrandId",
table: "Phones");
migrationBuilder.DropColumn(
name: "BrandId",
table: "Phones");
migrationBuilder.AddColumn<string>(
name: "Company",
table: "Phones",
type: "TEXT",
nullable: true);
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PhoneStore.Models;
namespace PhoneStore.Migrations
{
[DbContext(typeof(MobileContext))]
[Migration("20220630161925_AddImageField")]
partial class AddImageField
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.17");
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Baskets");
});
modelBuilder.Entity("PhoneStore.Models.Brand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Brands");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Address")
.HasColumnType("TEXT");
b.Property<string>("ContactPhone")
.HasColumnType("TEXT");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Orders");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("BrandId")
.HasColumnType("INTEGER");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<decimal>("Price")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("BrandId");
b.ToTable("Phones");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.HasOne("PhoneStore.Models.Brand", "Brand")
.WithMany()
.HasForeignKey("BrandId");
b.Navigation("Brand");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PhoneStore.Migrations
{
public partial class AddImageField : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones");
migrationBuilder.AlterColumn<int>(
name: "BrandId",
table: "Phones",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AddColumn<string>(
name: "Image",
table: "Phones",
type: "TEXT",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones",
column: "BrandId",
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.Sql(@$"UPDATE ""Phones""
SET ""Image"" = 'images\phoneImages\default.jpg'
WHERE ""Image"" IS NULL;");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones");
migrationBuilder.DropColumn(
name: "Image",
table: "Phones");
migrationBuilder.AlterColumn<int>(
name: "BrandId",
table: "Phones",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones",
column: "BrandId",
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PhoneStore.Models;
namespace PhoneStore.Migrations
{
[DbContext(typeof(MobileContext))]
partial class MobileContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.17");
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Baskets");
});
modelBuilder.Entity("PhoneStore.Models.Brand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Brands");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Address")
.HasColumnType("TEXT");
b.Property<string>("ContactPhone")
.HasColumnType("TEXT");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Orders");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("BrandId")
.HasColumnType("INTEGER");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<decimal>("Price")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("BrandId");
b.ToTable("Phones");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.HasOne("PhoneStore.Models.Brand", "Brand")
.WithMany()
.HasForeignKey("BrandId");
b.Navigation("Brand");
});
#pragma warning restore 612, 618
}
}
}
...@@ -8,6 +8,7 @@ namespace PhoneStore.Models ...@@ -8,6 +8,7 @@ namespace PhoneStore.Models
public DbSet<Order> Orders { get; set; } public DbSet<Order> Orders { get; set; }
public DbSet<Basket> Baskets { get; set; } public DbSet<Basket> Baskets { get; set; }
public DbSet<Brand> Brands { get; set; } public DbSet<Brand> Brands { get; set; }
public DbSet<User> Users { get; set; }
public MobileContext(DbContextOptions<MobileContext> options) : base(options) public MobileContext(DbContextOptions<MobileContext> options) : base(options)
{ {
......
using System.ComponentModel;
namespace PhoneStore.Models
{
public class User
{
public int Id { get; set; }
[DisplayName("Имя")]
public string Name { get; set; }
[DisplayName("Возраст")]
public int Age { get; set; }
}
}
\ No newline at end of file
...@@ -9,15 +9,11 @@ ...@@ -9,15 +9,11 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.17" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\Files\book.pdf" /> <_ContentIncludedByDefault Remove="wwwroot\Files\book.pdf" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
</Project> </Project>
...@@ -25,7 +25,7 @@ namespace PhoneStore ...@@ -25,7 +25,7 @@ namespace PhoneStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
string connection = Configuration.GetConnectionString("DefaultConnection"); string connection = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<MobileContext>(options => options.UseSqlite(connection)); services.AddDbContext<MobileContext>(options => options.UseNpgsql(connection));
services.AddControllersWithViews(); services.AddControllersWithViews();
services.AddScoped<IBasketService, BasketService>(); services.AddScoped<IBasketService, BasketService>();
services.AddTransient<UploadService>(); services.AddTransient<UploadService>();
......
using System;
namespace PhoneStore.ViewModels
{
public class PageViewModel
{
public int Page { get; set; }
public int TotalPages { get; set; }
public bool HasPrevious => Page > 1;
public bool HasNext => Page < TotalPages;
public PageViewModel(int page, int count, int pageSize)
{
Page = page;
TotalPages = (int)Math.Ceiling(count / (double)pageSize);
}
}
}
\ No newline at end of file
using System.Collections.Generic;
using PhoneStore.Models;
namespace PhoneStore.ViewModels
{
public class UsersViewModel
{
public IEnumerable<User> Users { get; set; }
public string Filter { get; set; }
public PageViewModel PageViewModel { get; set; }
}
}
\ No newline at end of file
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Brands" asp-action="Create">Добавить бренд</a> <a class="nav-link text-dark" asp-area="" asp-controller="Brands" asp-action="Create">Добавить бренд</a>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Users" asp-action="Index">Пользователи</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>
......
@model UsersViewModel
@{
ViewBag.Title = "Пользователи";
Layout = "_Layout";
}
<h2>Список пользователей</h2>
<div class="row">
<div class="phone_add_form col-md-6">
<form asp-action="Index" asp-controller="Users" method="get">
<div class="form_row">
<label for="name">
Имя:
<input
id="name"
type="text"
name="filteringCriterionByName"
value="@Model.Filter">
</label>
<input type="text" hidden name="page" value="@Model.PageViewModel.Page">
<button class="btn btn-outline-warning">Отправить</button>
</div>
</form>
</div>
</div>
<table style="width: 100%">
<tr>
<th>
<a
asp-action="Index"
asp-controller="Users"
asp-route-order="@ViewBag.NameSort"
asp-route-filteringCriterionByName="@Model.Filter">
Имя
</a>
</th>
<th>
<a
asp-action="Index"
asp-controller="Users"
asp-route-order="@ViewBag.AgeSort"
asp-route-filteringCriterionByName="@Model.Filter">
Возраст
</a>
</th>
</tr>
@foreach (var user in Model.Users)
{
<tr>
<td>@user.Name</td>
<td>@user.Age</td>
</tr>
}
</table>
@if (Model.PageViewModel.HasPrevious)
{
<a asp-action="Index" asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page - 1)"
asp-route-filteringCriterionByName="@Model.Filter"
class="btn btn-outline-warning">Назад</a>
}
@if (Model.PageViewModel.HasNext)
{
<a asp-action="Index" asp-controller="Users"
asp-route-page="@(Model.PageViewModel.Page + 1)"
asp-route-filteringCriterionByName="@Model.Filter"
class="btn btn-outline-warning">Вперед</a>
}
\ No newline at end of file
{ {
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "Data Source=Mobile.db;" "DefaultConnection": "Server=localhost;Port=54320;Username=postgres;Password=postgres;"
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment