From 54d03d472084be1ab8e36739cc8f9b5f6a2fabeb Mon Sep 17 00:00:00 2001 From: Anton Mitsengendler Date: Mon, 18 Feb 2019 18:13:26 +0300 Subject: [PATCH] fixed tracked entity issue localized validation strings --- Controllers/PhoneBookController.cs | 4 ++-- Models/BookEntry.cs | 8 ++++---- PhoneEdit.csproj | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Controllers/PhoneBookController.cs b/Controllers/PhoneBookController.cs index bb09b4d..a4424bb 100644 --- a/Controllers/PhoneBookController.cs +++ b/Controllers/PhoneBookController.cs @@ -191,8 +191,8 @@ private bool BookEntryExists(int id) // Valid only if personnelNumber is unique private bool VerifyPersonnelNumber(string personnelNumber, int id) { - var entry = _context.Entries.FirstOrDefault(e => e.PersonnelNumber == personnelNumber); - return entry == null || entry.Id == id; + var entry = _context.Entries.AsNoTracking().FirstOrDefault(e => e.PersonnelNumber == personnelNumber); + return (entry == null || entry.Id == id); } private bool VerifyPersonnelNumber(BookEntry entry) diff --git a/Models/BookEntry.cs b/Models/BookEntry.cs index 5a95982..8d1519d 100644 --- a/Models/BookEntry.cs +++ b/Models/BookEntry.cs @@ -12,21 +12,21 @@ public partial class BookEntry [HiddenInput(DisplayValue = false)] public int Id { get; set; } - [Required] + [Required(ErrorMessage = "Поле обязательно для заполнения")] [Remote(action: "RemoteVerifyPersonnelNumber", controller: "PhoneBook", AdditionalFields = nameof(Id))] [DisplayName("Табельный номер")] public string PersonnelNumber { get; set; } - [Required] + [Required(ErrorMessage = "Поле обязательно для заполнения")] [DisplayName("ФИО")] public string Name { get; set; } - [Required] + [Required(ErrorMessage = "Поле обязательно для заполнения")] [DisplayName("Должность")] public string Position { get; set; } - [Required] + [Required(ErrorMessage = "Поле обязательно для заполнения")] [DisplayName("Подразделение")] public string Department { get; set; } diff --git a/PhoneEdit.csproj b/PhoneEdit.csproj index e61518e..0bc6caf 100644 --- a/PhoneEdit.csproj +++ b/PhoneEdit.csproj @@ -7,6 +7,8 @@ + +