Implement edit page for document companies.

This commit is contained in:
2019-06-30 12:22:49 +01:00
parent 88a2d670e5
commit 64d7d702a9
3 changed files with 20 additions and 11 deletions

View File

@@ -80,8 +80,11 @@ namespace cicm_web.Areas.Admin.Controllers
if(id == null) return NotFound(); if(id == null) return NotFound();
DocumentCompany documentCompany = await _context.DocumentCompanies.FindAsync(id); DocumentCompany documentCompany = await _context.DocumentCompanies.FindAsync(id);
if(documentCompany == null) return NotFound(); if(documentCompany == null) return NotFound();
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new {c.Id, c.Name}), "Id", "Name", documentCompany.CompanyId);
return View(documentCompany); return View(documentCompany);
} }
@@ -111,6 +114,8 @@ namespace cicm_web.Areas.Admin.Controllers
return RedirectToAction(nameof(Index)); return RedirectToAction(nameof(Index));
} }
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new {c.Id, c.Name}), "Id", "Name", documentCompany.CompanyId);
return View(documentCompany); return View(documentCompany);
} }

View File

@@ -6,7 +6,7 @@
<h1>Edit</h1> <h1>Edit</h1>
<h4>DocumentCompany</h4> <h4>Document company</h4>
<hr /> <hr />
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
@@ -25,14 +25,17 @@
</span> </span>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="CompanyId" <label asp-for="Company"
class="control-label"> class="control-label">
</label> </label>
<input asp-for="CompanyId" <select asp-for="CompanyId"
class="form-control" /> class="form-control"
<span asp-validation-for="CompanyId" asp-items="ViewBag.CompanyId">
class="text-danger"> <option selected
</span> value="">
None or unknown
</option>
</select>
</div> </div>
<input type="hidden" <input type="hidden"
asp-for="Id" /> asp-for="Id" />
@@ -40,11 +43,12 @@
<input class="btn btn-primary" <input class="btn btn-primary"
type="submit" type="submit"
value="Save" /> value="Save" />
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<div> @section Scripts {
<a asp-action="Index">Back to List</a> @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
</div> }

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.857</Version> <Version>3.0.99.859</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>