mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add constraint to instruction set.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
@@ -42,6 +43,7 @@ namespace Cicm.Database.Models
|
||||
|
||||
[Required]
|
||||
[StringLength(45)]
|
||||
[Remote("VerifyUnique", "InstructionSets", "Admin")]
|
||||
public string Name { get; set; }
|
||||
|
||||
public virtual ICollection<Processor> Processors { get; set; }
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cicm.Database.Models;
|
||||
@@ -147,5 +148,11 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
return _context.InstructionSets.Any(e => e.Id == id);
|
||||
}
|
||||
|
||||
[AcceptVerbs("Get", "Post")]
|
||||
public IActionResult VerifyUnique(string name) =>
|
||||
_context.InstructionSets.Any(i => string.Equals(i.Name, name, StringComparison.InvariantCultureIgnoreCase))
|
||||
? Json("Instruction set already exists.")
|
||||
: Json(true);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.518</Version>
|
||||
<Version>3.0.99.520</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