mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add constraint to instruction set extension.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
@@ -44,6 +45,7 @@ namespace Cicm.Database.Models
|
||||
[DisplayName("Name")]
|
||||
[Required]
|
||||
[StringLength(45)]
|
||||
[Remote("VerifyUnique", "InstructionSetExtensions", "Admin")]
|
||||
public string Extension { get; set; }
|
||||
|
||||
public virtual ICollection<InstructionSetExtensionsByProcessor> InstructionSetExtensionsByProcessor
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cicm.Database.Models;
|
||||
@@ -49,7 +50,8 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
}
|
||||
|
||||
// GET: Admin/InstructionSetExtensions
|
||||
public async Task<IActionResult> Index() => View(await _context.InstructionSetExtensions.OrderBy(e => e.Extension).ToListAsync());
|
||||
public async Task<IActionResult> Index() =>
|
||||
View(await _context.InstructionSetExtensions.OrderBy(e => e.Extension).ToListAsync());
|
||||
|
||||
// GET: Admin/InstructionSetExtensions/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
@@ -152,5 +154,12 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
return _context.InstructionSetExtensions.Any(e => e.Id == id);
|
||||
}
|
||||
|
||||
[AcceptVerbs("Get", "Post")]
|
||||
public IActionResult VerifyUnique(string extension) =>
|
||||
_context.InstructionSetExtensions.Any(i => string.Equals(i.Extension, extension,
|
||||
StringComparison.InvariantCultureIgnoreCase))
|
||||
? Json("Instruction set extension already exists.")
|
||||
: Json(true);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.520</Version>
|
||||
<Version>3.0.99.521</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