public virtual Task <CartAggregate> AddGiftItemsAsync(IReadOnlyCollection <string> giftIds, IReadOnlyCollection <GiftItem> availableGifts) { EnsureCartExists(); if (!giftIds.IsNullOrEmpty()) { foreach (var giftId in giftIds) { var availableGift = availableGifts.FirstOrDefault(x => x.Id == giftId); if (availableGift == null) { // ignore the gift, if it's not in available gifts list continue; } var giftItem = GiftItems.FirstOrDefault(x => x.EqualsReward(availableGift)); if (giftItem == null) { giftItem = _mapper.Map <LineItem>(availableGift); giftItem.Id = null; giftItem.IsGift = true; giftItem.CatalogId ??= ""; giftItem.ProductId ??= ""; giftItem.Sku ??= ""; giftItem.Currency = Currency.Code; Cart.Items.Add(giftItem); } giftItem.IsRejected = false; } } return(Task.FromResult(this)); }
////////////////////////////////////////////////////////////////////////////////////////// ///// Останавливаем Ивент ////////////////////////////////////////////////////////////////////////////////////////// void cmdFarmingStop(bool finnish = false) { if (finnish || playersWin.Count > 0) { cmdFarmingStat(true); if (configData.giveGift) { GiftItems ItemGift = null; if (!configData.giveRandomAllGift) { int rand = UnityEngine.Random.Range(0, configData.listGiftItems.Count); ItemGift = configData.listGiftItems[rand]; } foreach (var win in playersWin) { if (IsValidSession(FindSession(win.Key.ToString()))) { if (configData.giveRandomAllGift) { int rand = UnityEngine.Random.Range(0, configData.listGiftItems.Count); ItemGift = configData.listGiftItems[rand]; } string pName = ""; pName = FindSession(win.Key.ToString()).Identity.Name; if ((bool)this.GiveItem(FindSession(win.Key.ToString()), ItemGift.ItemIDNameGuID, ItemGift.itemCount)) { if (configData.showWinnerInChat) { BroadcastChat(GetMsg("msg_Prefix"), GetMsg("msg_Winner").Replace("{name}", pName).Replace("{gift}", ItemGift.itemName.ToString()).Replace("{cout}", ItemGift.itemCount.ToString())); } if (configData.writeWinLog) { LogToFile("WinLog", $"[" + System.DateTime.Now + "] " + pName + " (" + FindSession(win.Key.ToString()).SteamId + ") GIFT: " + ItemGift.itemName.ToString() + " IDorNAMEorGUID: " + ItemGift.ItemIDNameGuID.ToString() + " COUNT:" + ItemGift.itemCount.ToString(), this, true); } if (configData.showWinConsole) { Puts(pName + " (" + FindSession(win.Key.ToString()).SteamId + ") GIFT: " + ItemGift.itemName.ToString() + " IDorNAMEorGUID: " + ItemGift.ItemIDNameGuID.ToString() + " COUNT:" + ItemGift.itemCount.ToString()); } } } } } } else { BroadcastChat(GetMsg("msg_Prefix"), GetMsg("msg_Stop")); } currentFarmEvent.Time.Destroy(); currentFarmEvent.Progress.Destroy(); currentFarmEvent = new FarmEvent(); playersFarming.Clear(); playersWin.Clear(); farmStarted = false; }
public virtual CartAggregate RejectCartItems(IReadOnlyCollection <string> cartItemIds) { EnsureCartExists(); if (cartItemIds.IsNullOrEmpty()) { return(this); } foreach (var cartItemId in cartItemIds) { var giftItem = GiftItems.FirstOrDefault(x => x.Id == cartItemId); if (giftItem != null) { RemoveItemAsync(giftItem.Id); } } return(this); }