0
0

Add action for adding new bundles

This commit is contained in:
Sergey Chebotar 2023-02-16 09:01:18 +03:00
parent b20759f205
commit dc58f242fa
3 changed files with 45 additions and 0 deletions

View File

@ -32,5 +32,16 @@ namespace MyDarling.Controllers
}
return RedirectToAction("Index");
}
public ActionResult Add()
{
return View();
}
[HttpPost]
public ActionResult Add(UnderwearBundle b)
{
repository.Add(b);
return RedirectToAction("Index");
}
}
}

33
Views/Bundles/Add.cshtml Normal file
View File

@ -0,0 +1,33 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@model MyDarling.Models.UnderwearBundle
<!DOCTYPE html>
<html>
<head>
<title>New bundle</title>
<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<container>
<form asp-action="Add" method="post" class="m-2">
<div asp-validation-summary="All"></div>
<div class="form-group">
<label asp-for="Name" class="form-label">Name:</label>
<input asp-for="Name" class="form-control" />
</div>
<div class="form-group">
<label asp-for="Description" class="form-label">Descrition:</label>
<input asp-for="Description" class="form-control" />
</div>
<div class="form-group">
<label asp-for="Price" class="form-label">Price:</label>
<input asp-for="Price" class="form-control" />
</div>
<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
</container>
</body>
</html>

View File

@ -34,6 +34,7 @@
}
</tbody>
</table>
<a asp-action="Add">Add bundle</a>
</container>
</body>