/// <summary> /// Логгирование авторизации /// </summary> private static void LogAuthorize(IResultValue <string> resultToken, IAuthorizeRestService service, IBoutiqueLogger boutiqueLogger) => resultToken. ResultValueVoidOkBad(_ => boutiqueLogger. Void(_ => boutiqueLogger.ShowMessage($"Токен сервиса [{service.GetType().Name}] получен")), errors => errors. Void(_ => boutiqueLogger.ShowMessage($"Ошибка авторизации в сервисе [{service.GetType().Name}]")). Void(_ => boutiqueLogger.ShowErrors(errors)));
/// <summary> /// Логгирование действия с базой /// </summary> public static void LogServiceAction <TId, TDomain>(IResultError result, IBoutiqueLogger boutiqueLogger, ServiceActionType serviceActionType) where TDomain : IDomainModel <TId> where TId : notnull => result. ResultErrorVoidOkBad(() => boutiqueLogger.ShowMessage($"{serviceActionType} [{typeof(TDomain).Name}] completed"), errors => errors. Void(_ => boutiqueLogger.ShowMessage($"Error {serviceActionType} [{typeof(TDomain).Name}]")). Void(_ => boutiqueLogger.ShowErrors(errors)));
/// <summary> /// Загрузить данные в базу /// </summary> public static async Task <IResultError> DeleteData(IRestHttpClient httpClient, IBoutiqueLogger boutiqueLogger) => await httpClient.ToResultValue(). Void(_ => boutiqueLogger.ShowMessage("Начало удаления данных")). ResultValueBindErrorsOkAsync(restClient => SizeGroupDelete(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => ClothesTypeDelete(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => GenderDelete(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => CategoryDelete(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => ColorDelete(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => SizeDelete(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => ClothesDelete(restClient, boutiqueLogger)). VoidTaskAsync(_ => boutiqueLogger.ShowMessage("Удаление данных завершено"));
/// <summary> /// Загрузить данные в базу /// </summary> public static async Task <IResultError> PostData(IRestHttpClient restClientBoutique, IBoutiqueLogger boutiqueLogger) => await restClientBoutique.ToResultValue(). Void(_ => boutiqueLogger.ShowMessage("Начало загрузки данных")). ResultValueBindErrorsOkAsync(restClient => GenderUpload(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => CategoryUpload(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => ColorUpload(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => ClothesTypeUpload(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => SizeUpload(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => SizeGroupUpload(restClient, boutiqueLogger)). ResultValueBindErrorsOkBindAsync(restClient => ClothesUpload(restClient, boutiqueLogger)). VoidTaskAsync(_ => boutiqueLogger.ShowMessage("Загрузка данных завершена"));
/// <summary> /// Получить конфигурацию авторизации /// </summary> public static async Task <IResultValue <IAuthorizeDomain> > GetConfiguration(IBoutiqueLogger boutiqueLogger) => await AuthorizeConfigurationManager.GetConfigurationAsync(). ResultValueVoidBadTaskAsync(errors => boutiqueLogger. Void(_ => boutiqueLogger.ShowMessage("Ошибка файла авторизации")). Void(_ => boutiqueLogger.ShowErrors(errors)));
/// <summary> /// Получить конфигурацию /// </summary> public static async Task <IResultValue <ILoaderConfigurationDomain> > GetConfiguration(IBoutiqueLogger boutiqueLogger) => await LoaderConfigurationManager.GetConfigurationAsync(). ResultValueVoidBadTaskAsync(errors => boutiqueLogger. Void(_ => boutiqueLogger.ShowMessage("Ошибка конфигурационного файла")). Void(_ => boutiqueLogger.ShowErrors(errors)));