Ejemplo n.º 1
0
 /// <summary>
 /// Найти подпись по имени
 /// </summary>
 public ISignatureLibraryApp FindByFullName(string fullName, DepartmentTypeApp departmentType) =>
 PersonsInformation.FindIndex(person => person.SurnameAndDepartmentEqual(fullName, departmentType)).
 WhereBad(foundIndex => foundIndex > -1,
          badFunc: _ => PersonsInformation.FindIndex(person => person.SurnameEqual(fullName))).
 WhereContinue(foundIndex => foundIndex > -1,
               okFunc: foundIndex => _signaturesLibrary.Values[foundIndex],
               badFunc: foundIndex => null);
Ejemplo n.º 2
0
 public PersonInformationApp(string surname, string name, string patronymic, DepartmentTypeApp departmentType,
                             Func <DepartmentTypeApp, string> departmentToString)
 {
     Surname = !surname.IsNullOrWhiteSpace()
               ? surname
               : throw new ArgumentNullException(nameof(surname));
     Name                = name ?? String.Empty;
     Patronymic          = patronymic ?? String.Empty;
     DepartmentType      = departmentType;
     _departmentToString = departmentToString ?? throw new ArgumentNullException(nameof(departmentToString));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Найти подписи по именам
 /// </summary>
 public IEnumerable <ISignatureLibraryApp> FindByFullNames(IEnumerable <string> fullNames, DepartmentTypeApp departmentType = DepartmentTypeApp.Unknown) =>
 fullNames.Select(fullName => FindByFullName(fullName, departmentType)).
 Where(signature => signature != null);
Ejemplo n.º 4
0
 /// <summary>
 /// Проверить отдел по его типу
 /// </summary>
 public DepartmentTypeApp CheckDepartmentAccordingToType(DepartmentTypeApp departmentType, PersonDepartmentType personDepartmentType) =>
 personDepartmentType switch
 {
Ejemplo n.º 5
0
 /// <summary>
 /// Найти подпись по имени или получить случайную
 /// </summary>
 public IResultAppValue <ISignatureLibraryApp> FindByFullNameOrRandom(string fullName, DepartmentTypeApp departmentType) =>
 new ResultAppValue <ISignatureLibraryApp>(FindByFullName(fullName, departmentType),
                                           new ErrorApplication(ErrorApplicationType.SignatureNotFound, $"Подпись по имени {fullName} не найдена")).
 ResultValueBadBind(_ => new ResultAppValue <ISignatureLibraryApp>(GetRandomSignature(),
                                                                   new ErrorApplication(ErrorApplicationType.SignatureNotFound,
                                                                                        "База подписей пуста")));
Ejemplo n.º 6
0
 /// <summary>
 /// Конвертировать тип цвета печати в версию из приложения
 /// </summary>
 public static DepartmentType FromApplication(DepartmentTypeApp departmentTypeApp) =>
 Enum.TryParse(departmentTypeApp.ToString(), true, out DepartmentType departmentType) ?
 departmentType :
 throw new FormatException(nameof(departmentTypeApp));
Ejemplo n.º 7
0
 /// <summary>
 /// Проверка фамилии и отдела
 /// </summary>
 public bool SurnameAndDepartmentEqual(string surname, DepartmentTypeApp departmentType) =>
 SurnameEqual(surname) && DepartmentType == departmentType;
Ejemplo n.º 8
0
 /// <summary>
 /// Конвертировать тип отдела в версию из приложения
 /// </summary>
 public static DepartmentType FromApplication(this DepartmentTypeApp departmentTypeApp) =>
 DepartmentToApplicationConverter.FromApplication(departmentTypeApp);