Skip to content

Commit e38f04f

Browse files
committed
Добавлен проект MVC
1 parent f84f964 commit e38f04f

File tree

15 files changed

+338
-0
lines changed

15 files changed

+338
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
/csharpTasks/task1/MyVector/MyVector/obj/Debug
1414
/dotNetBasics/Classes/bin/Debug
1515
/dotNetBasics/Classes/obj/Debug
16+
/MVC/.vs
17+
/MVC/MVC/bin/Debug/netcoreapp2.0
18+
/MVC/MVC/obj

MVC/MVC.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28010.2003
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVC", "MVC\MVC.csproj", "{44DC7213-2FEF-41F8-B65A-70A83F740630}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{44DC7213-2FEF-41F8-B65A-70A83F740630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{44DC7213-2FEF-41F8-B65A-70A83F740630}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{44DC7213-2FEF-41F8-B65A-70A83F740630}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{44DC7213-2FEF-41F8-B65A-70A83F740630}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {15CEB593-919F-42B6-8B95-CC3B694D8C9E}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using MVC.Models;
7+
8+
namespace MVC.Controllers
9+
{
10+
public class HomeController : Controller
11+
{
12+
public string Index() {
13+
return "Hello from Home/Index!";
14+
}
15+
16+
public IActionResult About()
17+
{
18+
return View();
19+
}
20+
21+
public IActionResult List()
22+
{
23+
return View();
24+
}
25+
26+
public string Show(Point p)
27+
{
28+
return $"(X: {p.X}, Y: {p.Y})";
29+
}
30+
}
31+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using MVC.Models;
7+
8+
namespace MVC.Controllers
9+
{
10+
public class PhoneController : Controller
11+
{
12+
List<Phone> phones;
13+
public PhoneController()
14+
{
15+
// Задаем структуру для отображения
16+
phones = new List<Phone>
17+
{
18+
new Phone {Id = 1, Name = "IPhone 8", Manufactorer = "Apple"},
19+
new Phone {Id = 2, Name = "Galaxy S9", Manufactorer = "Samsung"},
20+
new Phone {Id = 3, Name = "Nexus 5", Manufactorer = "Google"},
21+
new Phone {Id = 4, Name = "IPhone X", Manufactorer = "Apple"},
22+
new Phone {Id = 5, Name = "Note 8", Manufactorer = "Samsung"}
23+
};
24+
}
25+
public IActionResult Index()
26+
{
27+
return View(phones);
28+
}
29+
30+
public string Show(int id)
31+
{
32+
return $"{phones[id - 1].Name}";
33+
}
34+
35+
[HttpGet]
36+
public IActionResult Buy(int id)
37+
{
38+
ViewBag.PhoneId = id;
39+
return View(phones[id-1]);
40+
}
41+
42+
[HttpPost]
43+
public string Buy(int PhoneId, string User)
44+
{
45+
return $"Thanks, {User}, for the order {PhoneId}";
46+
}
47+
}
48+
}

MVC/MVC/MVC.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Folder Include="wwwroot\" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
13+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" />
14+
</ItemGroup>
15+
16+
</Project>

MVC/MVC/MVC.csproj.user

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth>
5+
<WebStackScaffolding_IsLayoutPageSelected>False</WebStackScaffolding_IsLayoutPageSelected>
6+
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
7+
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>False</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
8+
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
9+
<Controller_SelectedScaffolderCategoryPath>root/Controller</Controller_SelectedScaffolderCategoryPath>
10+
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
11+
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
12+
</PropertyGroup>
13+
</Project>

MVC/MVC/Models/Phone.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace MVC.Models
7+
{
8+
public class Phone
9+
{
10+
public int Id { get; set; }
11+
public string Name { get; set; }
12+
public string Manufactorer { get; set; }
13+
}
14+
}

MVC/MVC/Models/Point.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace MVC.Models
7+
{
8+
public class Point
9+
{
10+
public int X { get; set; }
11+
public int Y { get; set; }
12+
}
13+
}

MVC/MVC/Program.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace MVC
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
BuildWebHost(args).Run();
18+
}
19+
20+
public static IWebHost BuildWebHost(string[] args) =>
21+
WebHost.CreateDefaultBuilder(args)
22+
.UseStartup<Startup>()
23+
.Build();
24+
}
25+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:50983/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"MVC": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development"
23+
},
24+
"applicationUrl": "http://localhost:50984/"
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)