Fix nullable
This commit is contained in:
parent
09de4581a8
commit
df730da8eb
@ -12,7 +12,7 @@ namespace AccountContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string? Warnings { get; set; } = string.Empty;
|
||||
public float? Rating { get; set; }
|
||||
public float? Rating { get; set; } = null;
|
||||
public int RoleId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,9 @@ namespace AccountDatabaseImplement.Models
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Login { get; set; }
|
||||
public string? Warnings { get; set; }
|
||||
public float? Rating { get; set; }
|
||||
|
||||
public string? Warnings { get; set; } = null;
|
||||
public float? Rating { get; set; } = null;
|
||||
[Required]
|
||||
public int RoleId { get; set; }
|
||||
public virtual Role Role { get; set; } = new();
|
||||
|
@ -82,7 +82,7 @@ namespace AccountsView
|
||||
Id = _id ?? 0,
|
||||
Login = textBoxLogin.Text,
|
||||
Warnings = textBoxWarnings.Text,
|
||||
Rating = (float)controlInputRating.Value,
|
||||
Rating = controlInputRating.Value.HasValue ? (float)controlInputRating.Value.GetValueOrDefault() : null,
|
||||
RoleId = _roles.First(x => x.RoleName == comboBoxControlRole.SelectedValue).Id,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
@ -20,7 +20,7 @@ namespace AccountsView
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("Rating", true), ("Id", true), ("Login", true) });
|
||||
abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("Rating", false), ("Id", true), ("Login", true) });
|
||||
}
|
||||
|
||||
private void ролиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@ -43,6 +43,13 @@ namespace AccountsView
|
||||
var accounts = _logic.ReadList(null);
|
||||
if (accounts != null)
|
||||
{
|
||||
foreach (var account in accounts)
|
||||
{
|
||||
if (!account.Rating.HasValue)
|
||||
{
|
||||
account.Rating = 0;
|
||||
}
|
||||
}
|
||||
abazovTreeView.addItems(accounts);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user