using Autofac; using GreenTree.Nachtragsmanagement.Core; using GreenTree.Nachtragsmanagement.Services.Appendix; using GreenTree.Nachtragsmanagement.Services.Deviation; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GreenTree.Nachtragsmanagement.Services.Configuration { public class StatusConfigurationReference : IConfigurationReference { /// /// Id /// public Guid Id { get { return Guid.Parse("28A46681-C93E-47F6-99F3-1A6B344124C7"); } } /// /// Internal name /// public string Name { get { return "ConfigurationReference.StatusConfigurationReference"; } } /// /// Display name /// public string DisplayName { get { return "Vertragsabweichungsstatus"; } } /// /// Determines if mutiple values are selectable /// public bool IsMultipleSelection { get { return true; } } /// /// Get available values /// public ConfigurationReferenceElement[] GetAvailableValues() { var deviationService = Singleton.Instance.Resolve(); return deviationService .GetAllStatuses() .Select(s => new ConfigurationReferenceElement { Value = s.Id, Text = s.Description }) .ToArray(); } /// /// Transforms mutiple selected values into a single line value /// /// Selected values. public string TransformValueCollectionToValue(string[] values) { return String.Join(", ", values); } /// /// Transforms the single line value into a mutiple selected values /// /// Single line value. public string[] TransformValueToValueCollection(string value) { return String.IsNullOrEmpty(value) ? new string[0] : value.Split(',') .Select(s => s.Trim()) .ToArray(); } /// /// Converts the string converted value into strongly typed value /// /// The selected value. public T GetValue(string value) { return (T)((object)Convert.ToInt32(value)); } /// /// Converts the string converted values into strongly typed values /// /// The selected values. public T GetValues(string[] values) { if (values == null) return default(T); return (T)( (object) (values .Select(v => Convert.ToInt32(v)) .ToArray())); } } }