Example #1
0
        public void MarkAsShown(string offerId, ShopOfferPlacementType placement, ShopOffer shopOffer, bool popup)
        {
            OfferDataStateEntry entry          = AllOffersState.Where(y => y.OfferId == offerId).SingleOrDefault();
            PlacementTypeState  entryPlacement = AllPlacementTypeState.Where(y => y.PlacementType == placement).SingleOrDefault();

            if (entry == null)
            {
                entry                = new OfferDataStateEntry();
                entry.OfferId        = offerId;
                entry.ActivationDate = DateTime.UtcNow;
                entry.LastTimeShown  = DateTime.MinValue;
                AllOffersState.Add(entry);
            }
            else
            {
                if (shopOffer.Duration > 0)
                {
                    if (DateTime.UtcNow > entry.ActivationDate.AddHours(shopOffer.Duration))
                    {
                        entry.ActivationDate = DateTime.UtcNow;
                    }
                }
            }

            if (popup)
            {
                if (entryPlacement == null)
                {
                    entryPlacement = new PlacementTypeState();
                    entryPlacement.PlacementType = placement;
                    AllPlacementTypeState.Add(entryPlacement);
                }
                entryPlacement.LastTimeShown = DateTime.UtcNow;

                entry.LastTimeShown = DateTime.UtcNow;
            }



#if !BACKOFFICE
            CloudScriptMethod cloudScriptMethod = new CloudScriptMethod("RegisterOfferState", false);
            cloudScriptMethod.Params.Add("offerId", offerId);
            cloudScriptMethod.Params.Add("placement", placement.ToString());
            cloudScriptMethod.Params.Add("popup", popup.ToString());
            PlayFabManager.Instance.AddToStack("RegisterOfferState", cloudScriptMethod);
#endif
        }
 public void MarkAsShown(ShopOfferPlacementType placement, bool popup)
 {
     MetaDataStateBase.Current.OfferDataState.MarkAsShown(this.InternalId, placement, this, popup);
 }