Skip to content

Commit

Permalink
fixed tracked entity issue
Browse files Browse the repository at this point in the history
localized validation strings
  • Loading branch information
rumkit committed Feb 18, 2019
1 parent 4e67602 commit 54d03d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Controllers/PhoneBookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Models/BookEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
2 changes: 2 additions & 0 deletions PhoneEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="jquery-globalize" Version="1.3.0" />
<PackageReference Include="jquery.validation.globalize" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
Expand Down

0 comments on commit 54d03d4

Please sign in to comment.