public async Task Delete(ShopPrice price) { using (var db = _databaseService.Open <GameContext>()) await db.Prices.Where(x => x.Id == price.Id).DeleteAsync(); price.PriceGroup.Prices.Remove(price); }
/// <summary> /// Creates a new item /// </summary> /// <exception cref="CharacterException"></exception> public PlayerItem Create(ShopItemInfo shopItemInfo, ShopPrice price, byte color, uint effect, uint count) { var item = new PlayerItem(this, shopItemInfo, price, color, effect, DateTimeOffset.Now, count); _items.TryAdd(item.Id, item); Player.Session.SendAsync(new ItemUpdateInventoryAckMessage(InventoryAction.Add, item.Map <PlayerItem, ItemDto>())); return(item); }
/// <summary> /// Creates a new item /// </summary> public PlayerItem Create(ShopItemInfo shopItemInfo, ShopPrice price, byte color, uint effect, uint count) { var itemId = _idGeneratorService.GetNextId(IdKind.Item); var item = new PlayerItem(_gameDataService, this, itemId, shopItemInfo, price, color, effect, DateTimeOffset.Now, count); _items.TryAdd(item.Id, item); Player.Session.Send(new SInventoryActionAckMessage(InventoryAction.Add, item.Map <PlayerItem, ItemDto>())); return(item); }
public PriceViewModel(ShopPrice price) { Price = price; Delete = ReactiveCommand.CreateFromTask(DeleteImpl); Price.WhenAnyValue(_ => _.PeriodType.Value, _ => _.Period.Value, _ => _.Price.Value, _ => _.IsRefundable.Value, _ => _.Durability.Value, _ => _.IsEnabled.Value) .Where(x => IsInitialized.Value) .Throttle(TimeSpan.FromSeconds(2)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => UpdateImpl()); }
internal PlayerItem(Inventory inventory, ShopItemInfo itemInfo, ShopPrice price, byte color, uint effect, DateTimeOffset purchaseDate, uint count) { Inventory = inventory; Id = ItemIdGenerator.GetNextId(); ItemNumber = itemInfo.ShopItem.ItemNumber; PriceType = itemInfo.PriceGroup.PriceType; PeriodType = price.PeriodType; Period = price.Period; Color = color; Effect = effect; PurchaseDate = purchaseDate; _durability = price.Durability; _count = count; }
/// <summary> /// Creates a new item /// </summary> /// <exception cref="CharacterException"></exception> public PlayerItem CreateSilent(ShopItemInfo shopItemInfo, ShopPrice price, byte color, EffectNumber[] effects, uint count) { if (effects.Length == 0) { effects = new EffectNumber[] { 0 } } ; var item = new PlayerItem(this, shopItemInfo, price, color, effects, DateTimeOffset.Now, count); _items.TryAdd(item.Id, item); return(item); }
/// <summary> /// Creates a new item /// </summary> /// <exception cref="CharacterException"></exception> public PlayerItem Create(ShopItemInfo shopItemInfo, ShopPrice price, byte color, EffectNumber[] effects, uint count) { if (effects.Length == 0) { effects = new EffectNumber[] { 0 } } ; var item = new PlayerItem(this, shopItemInfo, price, color, effects, DateTimeOffset.Now, count); _items.TryAdd(item.Id, item); Player.Session.SendAsync( new ItemUpdateInventoryAckMessage(InventoryAction.Add, item.Map <PlayerItem, ItemDto>())); return(item); }
public async Task Update(ShopPrice price) { using (var db = _databaseService.Open <GameContext>()) { var periodType = (byte)price.PeriodType.Value; await db.Prices .Where(x => x.Id == price.Id) .UpdateAsync(x => new ShopPriceEntity { PeriodType = periodType, Period = (int)price.Period.Value, Price = price.Price.Value, IsRefundable = price.IsRefundable.Value, Durability = price.Durability.Value, IsEnabled = price.IsEnabled.Value }); } }
public void TestConstructor() { // Arrange Shop shop = new Shop(1, "4Launch"); ShopPrice shopPrice = new ShopPrice(shop, 400, "https://www.4launch.nl/product/390646/Intel-Broadwell-E-i7-6800K-3-40GHz-15MB-Box/tweakers"); // Act Shop shopPriceShop = shopPrice.Shop; double shopPricePrice = shopPrice.Price; string shopPriceProductURL = shopPrice.ProductURL; // Assert Assert.AreEqual(shop, shopPriceShop); Assert.AreEqual(400, shopPricePrice); Assert.AreEqual( "https://www.4launch.nl/product/390646/Intel-Broadwell-E-i7-6800K-3-40GHz-15MB-Box/tweakers", shopPriceProductURL); }