Добавил action Create в контроллер Products

parent 2f4e2186
......@@ -45,5 +45,19 @@ namespace Store.Controllers
Category = "TV"
});
}
[HttpGet]
public IActionResult Create()
{
return View();
}
[HttpPost]
public IActionResult Create(Product product)
{
return View("Details", product);
}
}
}
@model object
@{
Layout = null;
Layout = "_MainLayout";
}
<!DOCTYPE html>
<h2>Create product:</h2>
<hr/>
<form action="/Product/Create" method="post" >
<div class="form-group">
<label for="">Name</label>
<input type="text" class="form-control" id="Name" name="Name" placeholder="Enter name">
</div>
<div class="form-group">
<label for="">Category</label>
<input type="text" class="form-control" id="Category" name="Category" placeholder="Enter category">
</div>
<div class="form-group">
<label for="">Brand</label>
<input type="text" class="form-control" id="Brand" name="Brand" placeholder="Enter brand">
</div>
<div class="form-group">
<label for="">Amount</label>
<input type="text" class="form-control" id="Amount" name="Amount" placeholder="Enter amount">
</div>
<html>
<head>
<title>title</title>
</head>
<body>
<div>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
</body>
</html>
\ No newline at end of file
......@@ -24,6 +24,9 @@
<li>
<a href="/Product/Index">Main</a>
</li>
<li>
<a href="/Product/Create">Create</a>
</li>
</ul>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment