public virtual async Task DeleteDeviceAsync(IDeviceIdentifier deviceIdentifier)
        {
            using (UnitOfWorkManager.Current.SetTenantId(deviceIdentifier.TenantId))
            {
                await DeviceRepository.DeleteAsync(d => d.TenantId == deviceIdentifier.TenantId &&
                                                   d.Id == deviceIdentifier.DeviceId);

                await UnitOfWorkManager.Current.SaveChangesAsync();
            }
        }
Example #2
0
        /// <summary>
        /// Creates a new RatingViewModel.
        /// </summary>
        public RatingViewModel(IFoodService foodService, IPluginSettings pluginSettings,
                               INavigationService navigationService, IDeviceIdentifier deviceIdentifier,
                               Meal meal)
        {
            _foodService       = foodService;
            _pluginSettings    = pluginSettings;
            _navigationService = navigationService;
            _deviceIdentifier  = deviceIdentifier;

            Meal   = meal;
            Rating = UserRating.Neutral;
            Status = VoteStatus.Success;
        }
Example #3
0
        /// <summary>
        /// Removes a push device by device identifier.
        /// </summary>
        /// <param name="deviceIdentifier">The device identifier.</param>
        public virtual async Task RemoveAsync(IDeviceIdentifier deviceIdentifier)
        {
            try
            {
                using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
                {
                    await DeviceStore.DeleteDeviceAsync(deviceIdentifier);

                    await uow.CompleteAsync();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("RemoveAsync failed, device identifier: " + deviceIdentifier?.ToString(), ex);
            }
        }
Example #4
0
 /// <summary>
 /// Creates a new <see cref="DeviceIdentifier"/> object from any object implements <see cref="IDeviceIdentifier"/>.
 /// </summary>
 /// <param name="deviceIdentifier">Device identifier.</param>
 public static DeviceIdentifier ToDeviceIdentifier(this IDeviceIdentifier deviceIdentifier)
 {
     return(new DeviceIdentifier(deviceIdentifier.TenantId, deviceIdentifier.DeviceId));
 }