public ShopItemInfo(ShopItem shopItem, ShopItemInfoEntity entity, GameDataService gameDataService) { Id = entity.Id; PriceGroup = gameDataService.ShopPrices[entity.PriceGroupId]; EffectGroup = gameDataService.ShopEffects[entity.EffectGroupId]; IsEnabled = entity.IsEnabled; Discount = entity.DiscountPercentage; ShopItem = shopItem; }
public ShopItemInfo(ShopItem item, ShopItemInfoEntity entity) { Id = entity.Id; Item = item; var priceGroup = ShopService.Instance.PriceGroups.First(x => x.Id == entity.PriceGroupId); PriceGroup = new ReactiveProperty <ShopPriceGroup>(priceGroup); var effectGroup = ShopService.Instance.EffectGroups.First(x => x.Id == entity.EffectGroupId); EffectGroup = new ReactiveProperty <ShopEffectGroup>(effectGroup); DiscountPercentage = new ReactiveProperty <byte>(entity.DiscountPercentage); IsEnabled = new ReactiveProperty <bool>(entity.IsEnabled); }
public async Task NewItemInfo(ShopItem item) { using (var db = _databaseService.Open <GameContext>()) { var itemInfoEntity = new ShopItemInfoEntity { ShopItemId = item.ItemNumber, EffectGroupId = EffectGroups.First().Id, PriceGroupId = PriceGroups.First().Id }; db.ItemInfos.Add(itemInfoEntity); await db.SaveChangesAsync(); item.ItemInfos.Add(new ShopItemInfo(item, itemInfoEntity)); } }