示例#1
0
        public async Task Delete(ShopPriceGroup priceGroup)
        {
            using (var db = _databaseService.Open <GameContext>())
                await db.PriceGroups.Where(x => x.Id == priceGroup.Id).DeleteAsync();

            PriceGroups.Remove(priceGroup);
        }
示例#2
0
 public PriceGroupViewModel(ShopPriceGroup priceGroup)
 {
     PriceGroup = priceGroup;
     AddPrice   = ReactiveCommand.CreateFromTask(AddPriceImpl);
     Delete     = ReactiveCommand.CreateFromTask(DeleteImpl);
     PriceGroup.WhenAnyValue(x => x.Name.Value, x => x.PriceType.Value)
     .Where(x => IsInitialized.Value)
     .Throttle(TimeSpan.FromSeconds(2))
     .ObserveOn(RxApp.MainThreadScheduler)
     .Subscribe(_ => UpdateImpl());
 }
示例#3
0
 public async Task Update(ShopPriceGroup priceGroup)
 {
     using (var db = _databaseService.Open <GameContext>())
     {
         var priceType = (byte)priceGroup.PriceType.Value;
         await db.PriceGroups
         .Where(x => x.Id == priceGroup.Id)
         .UpdateAsync(x => new ShopPriceGroupEntity
         {
             Name      = priceGroup.Name.Value,
             PriceType = priceType
         });
     }
 }
示例#4
0
        public async Task NewPrice(ShopPriceGroup priceGroup)
        {
            using (var db = _databaseService.Open <GameContext>())
            {
                var priceEntity = new ShopPriceEntity
                {
                    PriceGroupId = priceGroup.Id
                };
                db.Prices.Add(priceEntity);
                await db.SaveChangesAsync();

                priceGroup.Prices.Add(new ShopPrice(priceGroup, priceEntity));
            }
        }