示例#1
0
        /// <summary>
        ///     Seeds current deviceViewModel with data asynchronously
        ///     Заполняет устройство тех данными
        /// </summary>
        protected async Task SeedingAsync()
        {
            var stringDriverId = this.DeviceContext.RelatedDriverId;

            if (string.IsNullOrEmpty(stringDriverId))
            {
                throw new SetupDriverException(LocalizationResources.Instance.NoAssociatedDriverExceptionMessage);
            }

            var driverPersistableContext = await _persistanceService.GetDriverPersistableContextAsync(
                Guid.Parse(stringDriverId));

            if (driverPersistableContext == null)
            {
                throw new SetupDriverException(
                          LocalizationResources.Instance.NotAccessFromPersistableToDriver +
                          stringDriverId);
            }
            var driverMomento = await driverPersistableContext.GetDriverMomentoAsync();

            if (driverMomento == null)
            {
                throw new SetupDriverException(
                          LocalizationResources.Instance.NotRestoreStateOfDriver + stringDriverId);
            }


            await driverPersistableContext.SaveDriverMomentoAsync(driverMomento);
        }