Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lesson49
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Пасько Виталий
Lesson49
Commits
87ee13bc
Commit
87ee13bc
authored
Jul 21, 2022
by
Пасько Виталий
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Удалить кастомного пользователя.
*** - Удалил класс кастомного пользователя. - Подключил пакет Identity ***
parent
da08ac38
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
193 additions
and
71 deletions
+193
-71
20220721200244_RemoveCustomUser.Designer.cs
...re/Migrations/20220721200244_RemoveCustomUser.Designer.cs
+141
-0
20220721200244_RemoveCustomUser.cs
PhoneStore/Migrations/20220721200244_RemoveCustomUser.cs
+31
-0
MobileContextModelSnapshot.cs
PhoneStore/Migrations/MobileContextModelSnapshot.cs
+0
-18
MobileContext.cs
PhoneStore/Models/MobileContext.cs
+0
-1
User.cs
PhoneStore/Models/User.cs
+14
-2
PhoneStore.csproj
PhoneStore/PhoneStore.csproj
+6
-5
UserService.cs
PhoneStore/Services/UserService.cs
+0
-44
Startup.cs
PhoneStore/Startup.cs
+1
-1
No files found.
PhoneStore/Migrations/20220721200244_RemoveCustomUser.Designer.cs
0 → 100644
View file @
87ee13bc
// <auto-generated />
using
System
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
PhoneStore.Models
;
namespace
PhoneStore.Migrations
{
[
DbContext
(
typeof
(
MobileContext
))]
[
Migration
(
"20220721200244_RemoveCustomUser"
)]
partial
class
RemoveCustomUser
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
)
.
HasAnnotation
(
"ProductVersion"
,
"5.0.17"
)
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
);
modelBuilder
.
Entity
(
"PhoneStore.Models.Basket"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"integer"
)
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
);
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"
)
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
);
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"
)
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
);
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"
)
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
);
b
.
Property
<
int
?>(
"BrandId"
)
.
HasColumnType
(
"integer"
);
b
.
Property
<
string
>(
"Image"
)
.
HasColumnType
(
"text"
);
b
.
Property
<
string
>(
"Name"
)
.
HasColumnType
(
"text"
);
b
.
Property
<
decimal
>(
"Price"
)
.
HasColumnType
(
"numeric"
);
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
}
}
}
PhoneStore/Migrations/20220721200244_RemoveCustomUser.cs
0 → 100644
View file @
87ee13bc
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
PhoneStore.Migrations
{
public
partial
class
RemoveCustomUser
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"Users"
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"Users"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
int
>(
type
:
"integer"
,
nullable
:
false
)
.
Annotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
),
Age
=
table
.
Column
<
int
>(
type
:
"integer"
,
nullable
:
false
),
Name
=
table
.
Column
<
string
>(
type
:
"text"
,
nullable
:
true
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Users"
,
x
=>
x
.
Id
);
});
}
}
}
PhoneStore/Migrations/MobileContextModelSnapshot.cs
View file @
87ee13bc
...
...
@@ -103,24 +103,6 @@ namespace PhoneStore.Migrations
b
.
ToTable
(
"Phones"
);
});
modelBuilder
.
Entity
(
"PhoneStore.Models.User"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
()
.
HasColumnType
(
"integer"
)
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
);
b
.
Property
<
int
>(
"Age"
)
.
HasColumnType
(
"integer"
);
b
.
Property
<
string
>(
"Name"
)
.
HasColumnType
(
"text"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Users"
);
});
modelBuilder
.
Entity
(
"PhoneStore.Models.Basket"
,
b
=>
{
b
.
HasOne
(
"PhoneStore.Models.Phone"
,
"Phone"
)
...
...
PhoneStore/Models/MobileContext.cs
View file @
87ee13bc
...
...
@@ -8,7 +8,6 @@ namespace PhoneStore.Models
public
DbSet
<
Order
>
Orders
{
get
;
set
;
}
public
DbSet
<
Basket
>
Baskets
{
get
;
set
;
}
public
DbSet
<
Brand
>
Brands
{
get
;
set
;
}
public
DbSet
<
User
>
Users
{
get
;
set
;
}
public
MobileContext
(
DbContextOptions
<
MobileContext
>
options
)
:
base
(
options
)
{
...
...
PhoneStore/Models/User.cs
View file @
87ee13bc
using
Microsoft.AspNetCore.Identity
;
namespace
PhoneStore.Models
{
public
class
User
public
class
User
:
IdentityUser
<
int
>
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
int
Age
{
get
;
set
;
}
}
public
class
ApplicationRole
:
IdentityRole
<
int
>
{
public
ApplicationRole
()
:
base
()
{
}
public
ApplicationRole
(
string
roleName
)
:
base
(
roleName
)
{
}
}
}
\ No newline at end of file
PhoneStore/PhoneStore.csproj
View file @
87ee13bc
...
...
@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
...
...
PhoneStore/Services/UserService.cs
deleted
100644 → 0
View file @
da08ac38
using
System.Threading.Tasks
;
using
Microsoft.Extensions.Configuration
;
using
PhoneStore.Helpers
;
using
PhoneStore.Models
;
using
PhoneStore.Services.Abstractions
;
using
PhoneStore.ViewModels
;
using
Order
=
PhoneStore
.
Enums
.
Order
;
namespace
PhoneStore.Services
{
public
class
UserService
:
IUserService
{
private
readonly
MobileContext
_db
;
private
readonly
IUsersSortService
_sortService
;
private
readonly
IUsersFilter
_usersFilter
;
private
readonly
IPaginationService
<
User
>
_paginationService
;
private
readonly
IConfiguration
_configuration
;
public
UserService
(
MobileContext
db
,
IUsersSortService
sortService
,
IUsersFilter
usersFilter
,
IPaginationService
<
User
>
paginationService
,
IConfiguration
configuration
)
{
_db
=
db
;
_sortService
=
sortService
;
_usersFilter
=
usersFilter
;
_paginationService
=
paginationService
;
_configuration
=
configuration
;
}
public
async
Task
<
UsersViewModel
>
GetAll
(
Order
order
,
string
filterByName
,
int
page
)
{
var
pageSize
=
int
.
Parse
(
_configuration
[
"UsersPageSize"
]);
var
users
=
_db
.
Users
.
AsQueryable
();
var
filteredUsers
=
_usersFilter
.
FilterByName
(
users
,
filterByName
);
var
sortedUsers
=
_sortService
.
Sort
(
filteredUsers
,
order
);
var
(
queryable
,
count
)
=
await
_paginationService
.
GetABatchOfData
(
sortedUsers
,
page
,
pageSize
);
return
queryable
.
MapToUsersViewModel
(
filterByName
,
page
,
count
,
pageSize
);
}
}
}
\ No newline at end of file
PhoneStore/Startup.cs
View file @
87ee13bc
...
...
@@ -32,7 +32,7 @@ namespace PhoneStore
services
.
AddTransient
<
IDefaultPhoneImagePathProvider
>(
_
=>
new
DefaultPhoneImagePathProvider
(
Configuration
[
"PathToDefaultAvatar:Path"
]));
services
.
AddTransient
<
IPhoneService
,
PhoneService
>();
services
.
AddTransient
<
IUserService
,
UserService
>();
//
services.AddTransient<IUserService, UserService>();
services
.
AddTransient
<
IUsersSortService
,
UsersSortService
>();
services
.
AddTransient
<
IUsersFilter
,
UsersFilter
>();
services
.
AddTransient
<
IPaginationService
<
User
>,
PaginationService
<
User
>>();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment