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
ea4d4d75
Commit
ea4d4d75
authored
Jun 15, 2019
by
Нурбек Созоев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Вынес файл Repository.cs в папку Repositories
parent
534ca999
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
14 deletions
+72
-14
HomeController.cs
MyCities/Controllers/HomeController.cs
+6
-5
PersonController.cs
MyCities/Controllers/PersonController.cs
+15
-0
Person.cs
MyCities/Models/Person.cs
+9
-0
ICityRepository.cs
MyCities/Repositories/ICityRepository.cs
+12
-0
InMemoryCityRepository.cs
MyCities/Repositories/InMemoryCityRepository.cs
+3
-8
Startup.cs
MyCities/Startup.cs
+2
-1
Index.cshtml
MyCities/Views/Person/Index.cshtml
+25
-0
No files found.
MyCities/Controllers/HomeController.cs
View file @
ea4d4d75
using
Microsoft.AspNetCore.Mvc
;
using
MyCities.Models
;
using
MyCities.Repositories
;
namespace
MyCities.Controllers
{
public
class
HomeController
:
Controller
{
private
I
Repository
_r
epository
;
private
I
CityRepository
_cityR
epository
;
public
HomeController
(
I
Repository
r
epository
)
public
HomeController
(
I
CityRepository
cityR
epository
)
{
_
repository
=
r
epository
;
_
cityRepository
=
cityR
epository
;
}
public
IActionResult
Index
()
{
return
View
(
_
r
epository
.
Cities
);
return
View
(
_
cityR
epository
.
Cities
);
}
[
HttpGet
]
...
...
@@ -26,7 +27,7 @@ namespace MyCities.Controllers
[
HttpPost
]
public
IActionResult
Create
(
City
city
)
{
_
r
epository
.
Add
(
city
);
_
cityR
epository
.
Add
(
city
);
return
RedirectToAction
(
"Index"
);
}
}
...
...
MyCities/Controllers/PersonController.cs
0 → 100644
View file @
ea4d4d75
using
Microsoft.AspNetCore.Mvc
;
namespace
MyCities.Controllers
{
public
class
PersonController
:
Controller
{
// GET
public
IActionResult
Index
()
{
return
View
();
}
}
}
MyCities/Models/Person.cs
0 → 100644
View file @
ea4d4d75
namespace
MyCities.Models
{
public
class
Person
{
public
string
FullName
{
get
;
set
;
}
public
string
NickName
{
get
;
set
;
}
public
string
AvatarImagePath
{
get
;
set
;
}
}
}
MyCities/Repositories/ICityRepository.cs
0 → 100644
View file @
ea4d4d75
using
System.Collections.Generic
;
using
MyCities.Models
;
namespace
MyCities.Repositories
{
public
interface
ICityRepository
{
List
<
City
>
Cities
{
get
;
}
void
Add
(
City
city
);
}
}
MyCities/
Models/
Repository.cs
→
MyCities/
Repositories/InMemoryCity
Repository.cs
View file @
ea4d4d75
using
System.Collections.Generic
;
using
MyCities.Models
;
namespace
MyCities.
Model
s
namespace
MyCities.
Repositorie
s
{
public
interface
IRepository
{
List
<
City
>
Cities
{
get
;
}
void
Add
(
City
city
);
}
public
class
InMemoryRepository
:
IRepository
public
class
InMemoryCityRepository
:
ICityRepository
{
private
List
<
City
>
_cities
=
new
List
<
City
>
{
...
...
MyCities/Startup.cs
View file @
ea4d4d75
...
...
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
MyCities.Models
;
using
MyCities.Repositories
;
namespace
MyCities
{
...
...
@@ -32,7 +33,7 @@ namespace MyCities
options
.
MinimumSameSitePolicy
=
SameSiteMode
.
None
;
});
services
.
AddSingleton
<
I
Repository
,
InMemor
yRepository
>();
services
.
AddSingleton
<
I
CityRepository
,
InMemoryCit
yRepository
>();
services
.
AddMvc
().
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_2_1
);
}
...
...
MyCities/Views/Person/Index.cshtml
0 → 100644
View file @
ea4d4d75
@model IEnumerable<MyCities.Models.City>
@{ Layout = "_Layout";}
<table class="table small table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Counry</th>
<th>Population</th>
</tr>
</thead>
<tbody>
@foreach (var city in Model)
{
<tr>
<td>@city.Name</td>
<td>@city.Country</td>
<td>@city.Population.ToString("#,###")</td>
</tr>
}
</tbody>
</table>
<a href="/Home/Create" class="btn btn-primary">Create city</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