diff options
Diffstat (limited to 'tools/add-feature-template.sh')
| -rwxr-xr-x | tools/add-feature-template.sh | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/add-feature-template.sh b/tools/add-feature-template.sh index e5433f3..dd3d764 100755 --- a/tools/add-feature-template.sh +++ b/tools/add-feature-template.sh @@ -224,6 +224,26 @@ subdir="$dir/Views/$feature_name" mkdir -p $subdir cat > $subdir/Index.cshtml<< EOF +@model IEnumerable<${feature_name}WebModel> +@{ + ViewData["Title"] = "${feature_name}s"; +} + +<div> + @foreach (var item in Model) + { + <section> +$( +for feature in "${features[@]}"; do +echo -e "\t\t\t<div>\n\t\t\t\t@item.$(echo $feature | cut -d ' ' -f 2-)\n\t\t\t</div>" +done +) + </section> + } +</div> +EOF + +cat > $subdir/Details.cshtml<< EOF @model ${feature_name}WebModel @{ ViewData["Title"] = "$feature_name"; @@ -307,6 +327,8 @@ using $project_name.Services.Interfaces; using $project_name.Services.Models.$feature_name; using $project_name.Web.Models.$feature_name; using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using System.Linq; namespace $project_name.Web.Controllers { @@ -322,7 +344,18 @@ namespace $project_name.Web.Controllers } [HttpGet] - public async Task<IActionResult> Index(string id) + public async Task<IActionResult> Index() + { + List<${feature_name}ServiceModel> serviceModels = await this._service.GetAllAsync(); + + List<${feature_name}WebModel> webModel = serviceModels + .Select(x => this._autoMapper.Map<${feature_name}WebModel>(x)) + .ToList(); + return View(webModel); + } + + [HttpGet] + public async Task<IActionResult> Details(string id) { ${feature_name}ServiceModel serviceModel = await this._service.GetByIdAsync(Guid.Parse(id)); @@ -333,6 +366,7 @@ namespace $project_name.Web.Controllers return View(webModel); } + [HttpGet] public IActionResult Create() { |
