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); }
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()); }
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 }); } }
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)); } }