Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions WebStoreCoreApplication/Controler/BaseController.cs

This file was deleted.

50 changes: 50 additions & 0 deletions WebStoreCoreApplication/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Cache;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebStoreCoreApplication.ViewModels;

namespace WebStoreCoreApplication.Controllers
{
public class BaseController : Controller
{
private readonly List<EmployeeViewModel> _employees = new List<EmployeeViewModel>
{
new EmployeeViewModel
{
Id = 1,
Name = "Петр",
SName = "Петров",
FName = "Петрович",
Age = 33,
Position ="BOSS"
},
new EmployeeViewModel
{
Id = 2,
Name = "Фёдр",
SName = "Фёдоров",
FName = "Фёдорович",
Age = 25,
Position ="Программист"}
};
public IActionResult Index()
{
return View();
}

public IActionResult Employees()
{
return View(_employees);
}

public IActionResult EmployeeDetails(int id)
{
var employeeviewmodel = _employees.FirstOrDefault(x => x.Id == id);
if (employeeviewmodel == null) return NotFound();
return View(employeeviewmodel);
}
}
}
9 changes: 7 additions & 2 deletions WebStoreCoreApplication/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ namespace WebStoreCoreApplication
public class Startup
{
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -35,8 +40,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "Indes",
pattern: "New") ;
name: "default",
pattern: "{controller=Base}/{action=Index}/{id?}");
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync(hello);
Expand Down
17 changes: 17 additions & 0 deletions WebStoreCoreApplication/ViewModels/EmployeeViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebStoreCoreApplication.ViewModels
{
public class EmployeeViewModel
{
public int Id { get; set; }
public string Name { get; set;}
public string SName { get; set;}
public string FName { get; set;}
public int Age { get; set;}
public string Position { get; set;}
}
}
44 changes: 44 additions & 0 deletions WebStoreCoreApplication/Views/Base/EmployeeDetails.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@model WebStoreCoreApplication.ViewModels.EmployeeViewModel
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>EmployeeDetails</title>
</head>
<body>
<table class="table table-bordered">
<tr>
<td>ID</td>
<td>@Model.Id</td>
</tr>
<tr>
<td>Имя</td>
<td>@Model.Name</td>
</tr>
<tr>
<td>Фамилия</td>
<td>@Model.SName</td>
</tr>
<tr>
<td>Отчество</td>
<td>@Model.FName</td>
</tr>
<tr>
<td>Возраст</td>
<td>@Model.Age</td>
</tr>
<tr>
<td>Должность</td>
<td>@Model.Position</td>
</tr>
<td>
@Html.ActionLink("К списку", "Employees", new {})
</td>
</table>
</body>
</html>
29 changes: 29 additions & 0 deletions WebStoreCoreApplication/Views/Base/Employees.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@model IEnumerable<WebStoreCoreApplication.ViewModels.EmployeeViewModel>

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Employees</title>
</head>
<body>
<table class="table">
@foreach (var item in Model)
{
<tr>
<td>@item.Name</td>
<td>@item.SName</td>
<td>@item.FName</td>
<td>
@Html.ActionLink("Детали", "EmployeeDetails", new { id=item.Id})
</td>
</tr>
}
</table>
</body>
</html>
17 changes: 17 additions & 0 deletions WebStoreCoreApplication/Views/Base/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>

<p>Привет от вью</p>
</body>
</html>
9 changes: 9 additions & 0 deletions WebStoreCoreApplication/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}