Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
lesson60
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
Нурбек Созоев
lesson60
Commits
7d0e4d39
Commit
7d0e4d39
authored
May 29, 2019
by
Нурбек Созоев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил таблицу для отображения продуктов на странице /Product/Index
parent
10071420
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
ProductController.cs
Store/Controllers/ProductController.cs
+25
-0
Product.cs
Store/Models/Product.cs
+11
-0
Index.cshtml
Store/Views/Product/Index.cshtml
+30
-1
No files found.
Store/Controllers/ProductController.cs
View file @
7d0e4d39
using
System
;
using
System.Collections.Generic
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
Store.Models
;
namespace
Store.Controllers
namespace
Store.Controllers
{
{
...
@@ -6,6 +9,28 @@ namespace Store.Controllers
...
@@ -6,6 +9,28 @@ namespace Store.Controllers
{
{
public
IActionResult
Index
()
public
IActionResult
Index
()
{
{
List
<
Product
>
products
=
new
List
<
Product
>
{
new
Product
{
Id
=
Guid
.
NewGuid
().
ToString
(),
Name
=
"Asus A234"
,
Amount
=
100
,
Brand
=
"Asus"
,
Category
=
"TV"
},
new
Product
{
Id
=
Guid
.
NewGuid
().
ToString
(),
Name
=
"Asus A674"
,
Amount
=
150
,
Brand
=
"Asus"
,
Category
=
"TV"
}
};
ViewBag
.
products
=
products
;
return
View
();
return
View
();
}
}
}
}
...
...
Store/Models/Product.cs
0 → 100644
View file @
7d0e4d39
namespace
Store.Models
{
public
class
Product
{
public
string
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
string
Category
{
get
;
set
;
}
public
string
Brand
{
get
;
set
;
}
public
int
Amount
{
get
;
set
;
}
}
}
Store/Views/Product/Index.cshtml
View file @
7d0e4d39
@using Store.Models
@{
@{
Layout = "_MainLayout";
Layout = "_MainLayout";
}
}
<h1>Hello</h1>
<h2>Last products:</h2>
<hr/>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Category</th>
<th scope="col">Amount</th>
<th scope="col">Brand</th>
</tr>
</thead>
<tbody>
@foreach (Product product in ViewBag.products)
{
<tr>
<th scope="row">@product.Id</th>
<td>@product.Name</td>
<td>@product.Category</td>
<td>@product.Amount</td>
<td>@product.Brand</td>
</tr>
}
</tbody>
</table>
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