예제 #1
0
        public async Task Delete(ShopEffectGroup effectGroup)
        {
            using (var db = _databaseService.Open <GameContext>())
                await db.EffectGroups.Where(x => x.Id == effectGroup.Id).DeleteAsync();

            EffectGroups.Remove(effectGroup);
        }
 public EffectGroupViewModel(ShopEffectGroup effectGroup)
 {
     EffectGroup = effectGroup;
     AddEffect   = ReactiveCommand.CreateFromTask(AddEffectImpl);
     Delete      = ReactiveCommand.CreateFromTask(DeleteImpl);
     EffectGroup.WhenAnyValue(x => x.Name.Value)
     .Where(x => IsInitialized.Value)
     .Throttle(TimeSpan.FromSeconds(2))
     .ObserveOn(RxApp.MainThreadScheduler)
     .Subscribe(_ => UpdateImpl());
 }
예제 #3
0
 public async Task Update(ShopEffectGroup effectGroup)
 {
     using (var db = _databaseService.Open <GameContext>())
     {
         await db.EffectGroups
         .Where(x => x.Id == effectGroup.Id)
         .UpdateAsync(x => new ShopEffectGroupEntity
         {
             Name = effectGroup.Name.Value
         });
     }
 }
예제 #4
0
        public async Task NewEffect(ShopEffectGroup effectGroup)
        {
            using (var db = _databaseService.Open <GameContext>())
            {
                var effectEntity = new ShopEffectEntity
                {
                    EffectGroupId = effectGroup.Id
                };
                db.Effects.Add(effectEntity);
                await db.SaveChangesAsync();

                effectGroup.Effects.Add(new ShopEffect(effectGroup, effectEntity));
            }
        }