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]
|
[Required]
|
||||||
[DisplayName("Diagonal (inches)")]
|
[DisplayName("Diagonal (inches)")]
|
||||||
public double Diagonal { get; set; }
|
public double Diagonal { get; set; }
|
||||||
[Required]
|
|
||||||
[DisplayName("Native resolution")]
|
[DisplayName("Native resolution")]
|
||||||
public virtual Resolution NativeResolution { get; set; }
|
public virtual Resolution NativeResolution { get; set; }
|
||||||
[Range(2, 281474976710656)]
|
[Range(2, 281474976710656)]
|
||||||
@@ -41,5 +40,7 @@ namespace Cicm.Database.Models
|
|||||||
|
|
||||||
public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; }
|
public virtual ICollection<ResolutionsByScreen> Resolutions { get; set; }
|
||||||
public virtual ICollection<ScreensByMachine> ScreensByMachines { 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 Cicm.Database.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace cicm_web.Areas.Admin.Controllers
|
namespace cicm_web.Areas.Admin.Controllers
|
||||||
@@ -36,15 +37,24 @@ namespace cicm_web.Areas.Admin.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: Screens/Create
|
// 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
|
// POST: Screens/Create
|
||||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
// 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.
|
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Create([Bind("Width,Height,Diagonal,EffectiveColors,Type,Id")]
|
public async Task<IActionResult> Create(
|
||||||
Screen screen)
|
[Bind("Width,Height,Diagonal,EffectiveColors,Type,NativeResolutionId,Id")]
|
||||||
|
Screen screen)
|
||||||
{
|
{
|
||||||
if(ModelState.IsValid)
|
if(ModelState.IsValid)
|
||||||
{
|
{
|
||||||
@@ -53,6 +63,11 @@ namespace cicm_web.Areas.Admin.Controllers
|
|||||||
return RedirectToAction(nameof(Index));
|
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);
|
return View(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,16 @@
|
|||||||
<div asp-validation-summary="ModelOnly"
|
<div asp-validation-summary="ModelOnly"
|
||||||
class="text-danger">
|
class="text-danger">
|
||||||
</div>
|
</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">
|
<div class="form-group">
|
||||||
<label asp-for="Width"
|
<label asp-for="Width"
|
||||||
class="control-label">
|
class="control-label">
|
||||||
@@ -35,12 +45,14 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Diagonal"
|
<label asp-for="NativeResolution"
|
||||||
class="control-label">
|
class="control-label">
|
||||||
</label>
|
</label>
|
||||||
<input asp-for="Diagonal"
|
<select asp-for="NativeResolutionId"
|
||||||
class="form-control" />
|
class="form-control"
|
||||||
<span asp-validation-for="Diagonal"
|
asp-items="ViewBag.NativeResolutionId">
|
||||||
|
</select>
|
||||||
|
<span asp-validation-for="NativeResolutionId"
|
||||||
class="text-danger">
|
class="text-danger">
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -68,11 +80,15 @@
|
|||||||
<input class="btn btn-primary"
|
<input class="btn btn-primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
value="Create" />
|
value="Create" />
|
||||||
|
<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>
|
}
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Diagonal)
|
@Html.DisplayFor(modelItem => item.Diagonal)
|
||||||
</td>
|
</td>
|
||||||
<th>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.NativeResolution)
|
@item.NativeResolution.ToString()
|
||||||
</th>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.EffectiveColors)
|
@Html.DisplayFor(modelItem => item.EffectiveColors)
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -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.722</Version>
|
<Version>3.0.99.727</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>
|
||||||
|
|||||||
Reference in New Issue
Block a user