mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Implement create admin page for screens.
This commit is contained in:
@@ -16,7 +16,6 @@ namespace Cicm.Database.Models
|
||||
[Required]
|
||||
[DisplayName("Diagonal (inches)")]
|
||||
public double Diagonal { get; set; }
|
||||
[Required]
|
||||
[DisplayName("Native resolution")]
|
||||
public virtual Resolution NativeResolution { get; set; }
|
||||
[Range(2, 281474976710656)]
|
||||
@@ -41,5 +40,7 @@ namespace Cicm.Database.Models
|
||||
|
||||
public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; }
|
||||
public virtual ICollection<ScreensByMachine> ScreensByMachines { get; set; }
|
||||
[Required]
|
||||
public int NativeResolutionId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Cicm.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace cicm_web.Areas.Admin.Controllers
|
||||
@@ -36,14 +37,23 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
}
|
||||
|
||||
// GET: Screens/Create
|
||||
public IActionResult Create() => View();
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["NativeResolutionId"] =
|
||||
new
|
||||
SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Colors).Select(r => new {r.Id, Name = r.ToString()}),
|
||||
"Id", "Name");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Screens/Create
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create([Bind("Width,Height,Diagonal,EffectiveColors,Type,Id")]
|
||||
public async Task<IActionResult> Create(
|
||||
[Bind("Width,Height,Diagonal,EffectiveColors,Type,NativeResolutionId,Id")]
|
||||
Screen screen)
|
||||
{
|
||||
if(ModelState.IsValid)
|
||||
@@ -53,6 +63,11 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["NativeResolutionId"] =
|
||||
new
|
||||
SelectList(_context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height).ThenBy(r => r.Colors).Select(r => new {r.Id, Name = r.ToString()}),
|
||||
"Id", "Name");
|
||||
|
||||
return View(screen);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
<div asp-validation-summary="ModelOnly"
|
||||
class="text-danger">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Diagonal"
|
||||
class="control-label">
|
||||
</label>
|
||||
<input asp-for="Diagonal"
|
||||
class="form-control" />
|
||||
<span asp-validation-for="Diagonal"
|
||||
class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Width"
|
||||
class="control-label">
|
||||
@@ -35,12 +45,14 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Diagonal"
|
||||
<label asp-for="NativeResolution"
|
||||
class="control-label">
|
||||
</label>
|
||||
<input asp-for="Diagonal"
|
||||
class="form-control" />
|
||||
<span asp-validation-for="Diagonal"
|
||||
<select asp-for="NativeResolutionId"
|
||||
class="form-control"
|
||||
asp-items="ViewBag.NativeResolutionId">
|
||||
</select>
|
||||
<span asp-validation-for="NativeResolutionId"
|
||||
class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
@@ -68,11 +80,15 @@
|
||||
<input class="btn btn-primary"
|
||||
type="submit"
|
||||
value="Create" />
|
||||
<a asp-action="Index"
|
||||
class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
@section Scripts {
|
||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||
}
|
||||
@@ -38,9 +38,9 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Diagonal)
|
||||
</td>
|
||||
<th>
|
||||
@Html.DisplayFor(modelItem => item.NativeResolution)
|
||||
</th>
|
||||
<td>
|
||||
@item.NativeResolution.ToString()
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EffectiveColors)
|
||||
</td>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.722</Version>
|
||||
<Version>3.0.99.727</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user