Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
webinar63
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
Нурбек Созоев
webinar63
Commits
e9d79ea8
Commit
e9d79ea8
authored
Jun 15, 2019
by
Нурбек Созоев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил repository для модели Person
parent
ea4d4d75
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
10 deletions
+45
-10
PersonController.cs
MyCities/Controllers/PersonController.cs
+7
-1
IPersonRepository.cs
MyCities/Repositories/IPersonRepository.cs
+11
-0
InMemoryPersonRepository.cs
MyCities/Repositories/InMemoryPersonRepository.cs
+17
-0
Startup.cs
MyCities/Startup.cs
+1
-0
Index.cshtml
MyCities/Views/Person/Index.cshtml
+9
-9
No files found.
MyCities/Controllers/PersonController.cs
View file @
e9d79ea8
using
Microsoft.AspNetCore.Mvc
;
using
MyCities.Repositories
;
namespace
MyCities.Controllers
{
public
class
PersonController
:
Controller
{
private
IPersonRepository
_repository
;
public
PersonController
(
IPersonRepository
repository
)
{
_repository
=
repository
;
}
// GET
public
IActionResult
Index
()
{
return
View
();
return
View
(
_repository
.
Persons
);
}
}
}
MyCities/Repositories/IPersonRepository.cs
0 → 100644
View file @
e9d79ea8
using
System.Collections.Generic
;
using
MyCities.Models
;
namespace
MyCities.Repositories
{
public
interface
IPersonRepository
{
List
<
Person
>
Persons
{
get
;
}
void
Add
(
Person
person
);
}
}
MyCities/Repositories/InMemoryPersonRepository.cs
0 → 100644
View file @
e9d79ea8
using
System.Collections.Generic
;
using
MyCities.Models
;
namespace
MyCities.Repositories
{
public
class
InMemoryPersonRepository
:
IPersonRepository
{
private
List
<
Person
>
_persons
=
new
List
<
Person
>();
public
List
<
Person
>
Persons
=>
_persons
;
public
void
Add
(
Person
person
)
{
_persons
.
Add
(
person
);
}
}
}
MyCities/Startup.cs
View file @
e9d79ea8
...
...
@@ -34,6 +34,7 @@ namespace MyCities
});
services
.
AddSingleton
<
ICityRepository
,
InMemoryCityRepository
>();
services
.
AddSingleton
<
IPersonRepository
,
InMemoryPersonRepository
>();
services
.
AddMvc
().
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_2_1
);
}
...
...
MyCities/Views/Person/Index.cshtml
View file @
e9d79ea8
@model IEnumerable<MyCities.Models.
City
>
@model IEnumerable<MyCities.Models.
Person
>
@{ Layout = "_Layout";}
<table class="table small table-bordered">
<thead>
<tr>
<th>Name</th>
<th>
Counry
</th>
<th>
Population
</th>
<th>
Full
Name</th>
<th>
NickName
</th>
<th>
Avatar
</th>
</tr>
</thead>
<tbody>
@foreach (var
city
in Model)
@foreach (var
person
in Model)
{
<tr>
<td>@
city.
Name</td>
<td>@
city.Country
</td>
<td>
@city.Population.ToString("#,###")
</td>
<td>@
person.Full
Name</td>
<td>@
person.NickName
</td>
<td>
<img src="@person.AvatarImagePath" width="250" height="250"/>
</td>
</tr>
}
</tbody>
</table>
<a href="/
Home/Create" class="btn btn-primary">Create city
</a>
<a href="/
Person/Create" class="btn btn-primary">Create person
</a>
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