ExternalEntityLinkClientFunctions.cs
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.LongTermArchive.ExternalEntityLink;
using Sungero.Domain.Shared;
namespace DirRX.LongTermArchive.Client
{
partial class ExternalEntityLinkFunctions
{
// Выбрать сущность в диалоге.
public void SelectEntityItem()
{
if (string.IsNullOrWhiteSpace(_obj.EntityType))
Dialogs.ShowMessage(ExternalEntityLinks.Resources.EnterEntityTypeWarning, MessageType.Warning);
else
{
var allItems = Functions.ExternalEntityLink.Remote.GetEntities(_obj).ToArray();
if (allItems.Any())
{
var dialog = Dialogs.CreateInputDialog(ExternalEntityLinks.Resources.SelectEntityRecordDialogTitle);
var itemLabel = allItems.First().Info.LocalizedName;
var itemIds = allItems.Select(x => x.Id).ToArray();
var itemNames = allItems.Select(x => x.DisplayValue).ToArray();
var itemSelector = dialog.AddSelect(itemLabel, true).From(itemNames);
if (_obj.EntityId.HasValue)
itemSelector.ValueIndex = Array.IndexOf(itemIds, _obj.EntityId.Value);
if (dialog.Show() == DialogButtons.Ok)
{
_obj.EntityId = itemIds[itemSelector.ValueIndex];
}
}
else
Dialogs.ShowMessage(ExternalEntityLinks.Resources.ErrorEntityNotFound, MessageType.Error);
}
}
}
}