Exemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreateAdvertisingRequst advertisingRequst)
        {
            var advertize = new Advertising
            {
                ArabicDescription  = advertisingRequst.ArabicDescription,
                EnglishDescription = advertisingRequst.EnglishDescription,
                ImgUrl             = advertisingRequst.ImgUrl,
                Status             = advertisingRequst.Status
            };

            var status = await _advertisingService.CreateAdvertisingAsync(advertize);

            if (status == -1)
            {
                return(Conflict(new ErrorResponse
                {
                    message = "Dublicate Entry",
                    status = Conflict().StatusCode
                }));
            }

            if (status == 1)
            {
                var response = new BrandResponse {
                    Id = advertize.Id
                };
                return(Ok(response));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }
Exemplo n.º 2
0
    public static void ShowRewardedAds(RewardType rewardType, int Count)
    {
        if (IsRewardedAdReady() == false)
        {
            return;
        }

        instance.countToAdd = Count;
        switch (rewardType)
        {
        case RewardType.Coins:
            Advertising.RewardedAdCompleted += instance.RewardCoins;
            break;

        case RewardType.Gems:
            Advertising.RewardedAdCompleted += instance.RewardGems;
            break;

        case RewardType.Tickets:
            Advertising.RewardedAdCompleted += instance.RewardTickets;
            break;
        }

        Advertising.ShowRewardedAd(RewardedAdNetwork.UnityAds, AdPlacement.Default);
    }
Exemplo n.º 3
0
        public async Task <IActionResult> Update([FromRoute] Int32 AdvertiseId, [FromBody] UpdateAdvertisingRequest advertisingRequst)
        {
            var advertise = new Advertising
            {
                Id = AdvertiseId,
                ArabicDescription  = advertisingRequst.ArabicDescription,
                EnglishDescription = advertisingRequst.EnglishDescription,
                ImgUrl             = advertisingRequst.ImgUrl,
                Status             = advertisingRequst.Status
            };

            var status = await _advertisingService.UpdateAdvertisingAsync(advertise);

            if (status == -1)
            {
                return(Conflict(new ErrorResponse
                {
                    message = "Dublicate Entry",
                    status = Conflict().StatusCode
                }));
            }

            if (status == 1)
            {
                return(Ok(advertise));
            }

            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }
Exemplo n.º 4
0
 public static void ShowInterstitialAds()
 {
     if (IsInterstitialAdReady())
     {
         Advertising.ShowInterstitialAd(InterstitialAdNetwork.UnityAds, AdPlacement.Default);
     }
 }
Exemplo n.º 5
0
    public IEnumerator showBanner()
    {
        Advertising.ShowBannerAd(BannerAdPosition.Bottom);
        yield return(new WaitForSeconds(5f));

        Advertising.DestroyBannerAd();
    }
Exemplo n.º 6
0
    public void LoadeSceneName(string sceneName_)
    {
        sceneName = sceneName_;
        //StartCoroutine(AsyncLoad());
        if (AdManager.instance.adCounter > 1)
        {
            //запускаем межстрочное объявление
            AdManager.instance.adCounter = 0;

            // Check if interstitial ad is ready
            bool isReady = Advertising.IsInterstitialAdReady();

            // Show it if it's ready
            if (isReady)
            {
                Advertising.ShowInterstitialAd();
            }
            else
            {
                StartCoroutine(AsyncLoad());
            }
        }
        else
        {
            StartCoroutine(AsyncLoad());
        }
    }
Exemplo n.º 7
0
    //    private string adUnitId;
    //    private string appId;


    public void Start()
    {
        //npaSelected = false;
        //if (PlayerPrefs.HasKey("consentValue"))
        //{
        //    int thisValue = PlayerPrefs.GetInt("consentValue", 0);
        //    if (thisValue == 0)
        //    {
        //        Advertising.GrantDataPrivacyConsent();
        //        npaSelected = false;
        //        Debug.Log("personalized ads!");
        //    }
        //    else
        //    {
        //        Advertising.RevokeDataPrivacyConsent();
        //        npaSelected = true;
        //        Debug.Log("random ads!");
        //    }
        //}

        // Reads the current module-level consent of the Advertising module.
        ConsentStatus moduleConsent = Advertising.DataPrivacyConsent;

        Debug.Log("999 Consent status: " + moduleConsent);

        // Forward the consent to the Advertising module.
        //if (consent.advertisingConsent == ConsentStatus.Granted)
        //    Advertising.GrantDataPrivacyConsent();
        //else if (consent.advertisingConsent == ConsentStatus.Revoked)
        //    Advertising.RevokeDataPrivacyConsent();

        // Show banner ad

        Advertising.ShowBannerAd(BannerAdPosition.Bottom);
    }
        public async Task <IActionResult> Create(Advertising photo)
        {
            if (ModelState.IsValid)
            {
                return(View(photo));
            }

            //Save Photo
            if (!photo.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Image type is not valid");
                return(View());
            }
            //Image type is ok, chek size
            if (photo.Photo.IsSmaller(1))
            {
                ModelState.AddModelError("Photo", "Image type can be maximom 1mb");
                return(View());
            }
            //image size is ok, save the image
            photo.Image = await photo.Photo.SaveFileAsync(_env.WebRootPath, "img", "bg");

            await _context.Advertisings.AddRangeAsync(photo);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 9
0
        private void InitAds()
        {
            //Load an ad in advance to allow ample time for the ad to be loaded
            Advertising.LoadInterstitialAd();

            Advertising.InterstitialAdCompleted += InterstitialAdCompletedHandler;
        }
Exemplo n.º 10
0
 public void ShowBannerAd()
 {
     if (gm.ads)
     {
         Advertising.ShowBannerAd(BannerAdPosition.Bottom);
     }
 }
Exemplo n.º 11
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            Advertising AdvertItem = new Advertising();

            AdvertItem.ClassId    = Convert.ToInt32(ddl_type.SelectedValue);
            AdvertItem.AdvertName = txtAdvertName.Value;
            AdvertItem.AdvertLink = txt_link_url.Value;
            AdvertItem.AdvertPic  = txt_link_logo.Value;
            AdvertItem.SortId     = Convert.ToInt32(txt_sortid.Value);
            if (Id == 0)
            {
                if (AdvertBiz.AddAdvert(AdvertItem) > 0)
                {
                    base.ErrorMsg("提交成功!", "AdvertisingList.aspx", 1);
                }
                else
                {
                    base.ErrorMsg("提交失败!", "AdvertisingList.aspx", 0);
                }
            }
            else
            {
                AdvertItem.Id = Id;
                if (AdvertBiz.UpdateAdvert(AdvertItem) > 0)
                {
                    base.ErrorMsg("提交成功!", "AdvertisingList.aspx", 1);
                }
                else
                {
                    base.ErrorMsg("提交失败!", "AdvertisingList.aspx", 0);
                }
            }
        }
Exemplo n.º 12
0
        public Advertising[] GetAdvertising(int quantity)
        {
            if (quantity < 1)
            {
                throw new FaultException("Quantity = " + quantity + ". It must be > 0.");
            }

            Advertising[] advertising = new Advertising[quantity];
            Random        rand        = new Random();
            List <string> images      = new List <string>();

            foreach (var ext in extensions)
            {
                var a = Directory.GetFiles(imageDirectory, ext);
                images.AddRange(Directory.GetFiles(imageDirectory, ext));
            }

            if (images.Count() == 0)
            {
                throw new FaultException("No images in the specified folder: " + imageDirectory);
            }

            for (int i = 0; i < quantity; i++)
            {
                string imagePath = images[rand.Next(images.Count())];

                advertising[i] = new Advertising
                {
                    ImageData  = File.ReadAllBytes(imagePath),
                    Extensions = Path.GetExtension(imagePath)
                };
            }
            return(advertising);
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <returns>Dictionary pid和title</returns>
        public static Dictionary <string, string> GetADID(string code)
        {
            Advertising ad  = new Advertising().GetModelByCode(code);
            string      str = "0";
            Dictionary <string, string> dic = new Dictionary <string, string>();

            if (ad != null)
            {
                if (ad.ProductID != null)
                {
                    str = string.Join(",", ad.ProductID);
                }
                if (str == "")
                {
                    str = "0";
                }
                dic.Add("pid", str);
                dic.Add("title", ad.Title);
            }
            else
            {
                dic.Add("pid", str);
                dic.Add("title", " ");
            }
            return(dic);
        }
        public async Task <IActionResult> EditPost(int?id, Advertising a)
        {
            Advertising advertising = await _context.Advertisings.FindAsync(id);

            if (advertising == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            if (a.UpPhoto != null)
            {
                if (!a.UpPhoto.IsImage())
                {
                    ModelState.AddModelError("UpPhoto", "Plase PHOTO file choose");
                    return(View());
                }

                if (!a.UpPhoto.IsSmaller(1))
                {
                    ModelState.AddModelError("UpPhoto", "Plase PHOTO size maximum 1 mb must be");
                    return(View());
                }

                string filName = await a.UpPhoto.SaveFileAsync(_env.WebRootPath, "img", "bg");

                Utilities.Utility.DeleteImgFromFolder(_env.WebRootPath, @"img", @"bg", advertising.Image);
                advertising.Image = filName;

                advertising.Title = a.Title;
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 15
0
 public void ShowInterstitalAds()
 {
     if (Advertising.IsInterstitialAdReady())
     {
         Advertising.ShowInterstitialAd();
     }
 }
        public ActionResult Operation(Advertising inputs, string oldUrl)
        {
            ViewBag.userName = User.Identity.Name;
            //inputs.nameOfRegistrant = Session["USER"].ToString();
            String id = Session["userid"].ToString();


            inputs.date = DateTime.Now;
            PersianCalendar pc = new PersianCalendar();

            inputs.qdate = pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now);
            if (inputs.id == 0)
            {
                //Create Mode
                #region Create Advertising
                inputs.CreatedBy_id = int.Parse(id);
                var    image = Request.Files[0];
                string url   = "~/Images/ImageAd/" + DateTime.Now.Millisecond + image.FileName;
                if (image.FileName != "")
                {
                    if (image.ContentType == "image/jpeg" || image.ContentType == "image/jpg" || image.ContentType == "image/png")
                    {
                        if (image.ContentLength <= 1024000)
                        {
                            image.SaveAs(Server.MapPath(url));
                            inputs.imageUrl = url;
                            ViewBag.msg     = AdvertisingTable.Create(inputs);
                        }
                    }
                }
                #endregion
            }
            else
            {
                //Update Mode
                #region Update Advertising
                inputs.UpdatedBy_id = int.Parse(id);
                var    image = Request.Files[0];
                string url   = "~/Images/ImageAd/" + DateTime.Now.Millisecond + image.FileName;
                if (image.FileName != "")
                {
                    if (image.ContentType == "image/jpeg" || image.ContentType == "image/jpg" || image.ContentType == "image/png")
                    {
                        if (image.ContentLength <= 1024000)
                        {
                            System.IO.File.Delete(Server.MapPath(oldUrl));
                            image.SaveAs(Server.MapPath(url));
                            inputs.imageUrl = url;
                        }
                    }
                }
                else
                {
                    inputs.imageUrl = oldUrl;
                }
                AdvertisingTable.Update(inputs);
                #endregion
            }
            return(Redirect("/Advertising_p"));
        }
Exemplo n.º 17
0
 public void ShowRewardedAds()
 {
     if (Advertising.IsRewardedAdReady())
     {
         Advertising.ShowRewardedAd();
     }
 }
Exemplo n.º 18
0
    void Start()
    {
        // Show banner ad
        Advertising.ShowBannerAd(BannerAdPosition.Bottom);


        boTimerActive   = true;
        timer_coroutine = Timer();

        //current_level = starting_level;
        current_level = GetLevelToLoad();

        Load_level(current_level);

        if (mode == "BEGINNER")
        {
            DisplayHint();
        }

        if ((mode == "CHALLENGE") || (mode == "EXPERT"))
        {
            current_time = timerSpeed;
            Debug.Log("Starting Timer");

            StartCoroutine(timer_coroutine);
        }
    }
        void OnGameStateChanged(GameState newState, GameState oldState)
        {
            if (newState == GameState.Playing)
            {
                // This is when a new game starts being played.
            }
            else if (newState == GameState.GameOver)
            {
                // Show interstitial ad
                if (showInterstitialAd && !Advertising.IsAdRemoved())
                {
                    gameCount++;

                    if (gameCount >= gamesPerInterstitial)
                    {
                        if (Advertising.IsInterstitialAdReady())
                        {
                            // Show default ad after some optional delay
                            StartCoroutine(ShowInterstitial(showInterstitialDelay));

                            // Reset game count
                            gameCount = 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
///<summary>
///向数据库中添加一条记录
///</summary>
///<param name="model">要添加的实体</param>
        public bool Insert(Advertising model)
        {
            const string sql = @"INSERT INTO [dbo].[Advertising] (objectId,updatedAt,createdAt,title,url,pic,state) VALUES (@objectId,@updatedAt,@createdAt,@title,@url,@pic,@state)";
            int          res = SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@objectId", model.objectId.ToDBValue()), new SqlParameter("@updatedAt", model.updatedAt.ToDBValue()), new SqlParameter("@createdAt", model.createdAt.ToDBValue()), new SqlParameter("@title", model.title.ToDBValue()), new SqlParameter("@url", model.url.ToDBValue()), new SqlParameter("@pic", model.pic.ToDBValue()), new SqlParameter("@state", model.state.ToDBValue()));

            return(res > 0);
        }
Exemplo n.º 21
0
 void Start()
 {
     // Show banner ad
     if (showBannerAd && !Advertising.IsAdRemoved())
     {
         Advertising.ShowBannerAd(bannerAdPosition == BannerAdPos.Top ? BannerAdPosition.Top : BannerAdPosition.Bottom);
     }
 }
Exemplo n.º 22
0
 public void ShowRewardedAdToEarnCoins()
 {
     if (CanShowRewardedAd())
     {
         Advertising.RewardedAdCompleted += OnCompleteRewardedAdToEarnCoins;
         Advertising.ShowRewardedAd();
     }
 }
Exemplo n.º 23
0
 public void ShowRewardedAdToRecoverLostGame()
 {
     if (CanShowRewardedAd())
     {
         Advertising.RewardedAdCompleted += OnCompleteRewardedAdToRecoverLostGame;
         Advertising.ShowRewardedAd();
     }
 }
Exemplo n.º 24
0
 void Start()
 {
     // Show banner ad
     if (showBannerAd && !Advertising.IsAdRemoved())
     {
         Advertising.ShowBannerAd(bannerAdPosition);
     }
 }
Exemplo n.º 25
0
 private void Awake()
 {
     if (!RuntimeManager.IsInitialized())
     {
         RuntimeManager.Init();
         Advertising.GrantDataPrivacyConsent();
     }
 }
Exemplo n.º 26
0
 void LoadChooseModePage(Object sender, EventArgs e)
 {
     // SETUP ADVERTISEMENT:
     if (Globals.bDisplayAds)
     {
         Advertising.GetAdForGrid(LayoutRoot, 2, 0, 0);
     }
 }
Exemplo n.º 27
0
 public void DestroyBannerAd()
 {
     if (gm.ads)
     {
         Advertising.HideBannerAd();
         Advertising.DestroyBannerAd();
     }
 }
Exemplo n.º 28
0
        public override void OnEnter()
        {
            if (hideDefaultBannerAd.Value)
                Advertising.HideBannerAd();
            else
                Advertising.HideBannerAd(adNetwork, AdPlacement.Default);

            Finish();
        }
#pragma warning disable 0618

        public override void OnEnter()
        {
            Advertising.EnableAutoLoadDefaultAds(isAutoLoadDefaultAds.Value);

            if (!everyFrame)
            {
                Finish();
            }
        }
Exemplo n.º 30
0
        IEnumerator ShowInterstitial(float delay = 0f)
        {
            if (delay > 0)
            {
                yield return(new WaitForSeconds(delay));
            }

            Advertising.ShowInterstitialAd();
        }