Example #1
0
        public IActionResult FindUrl(long userid)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _env);

            AdsOffers lsturl = dbr.Single <AdsOffers>(t => t.UserId == userid);

            if (lsturl != null)
            {
                return(Ok(lsturl));
            }
            else
            {
                return(NotFound());
            }
        }
Example #2
0
        public IActionResult AddAdsUrl(long userId, string url)
        {
            try
            {
                var ads = new AdsOffers();

                var dbr = new DatabaseRepository(_logger, _env);

                var match = Regex.Match(url, @"^(?:\w+://)?([^/?]*)");

                var homePageUrl = match.Value;

                var lstAdsOffers = dbr.Find <AdsOffers>(t => t.UserId == userId || t.WebsiteUrl.Contains(homePageUrl));

                if (lstAdsOffers.Count != 0)
                {
                    return(BadRequest("Sorry, Either user or given url already register for this offer!"));
                }

                var contents = AdsOffersRepository.FindUrlForAds(homePageUrl);

                if (contents != "Ads found on website")
                {
                    return(BadRequest("Ads not found on website"));
                }

                var lstUser = dbr.Find <User>(t => t.Id == userId);

                var mailId = lstUser.First().EmailId;

                if (lstUser.Count > 0)
                {
                    ads.adsaccountstatus = AdsOfferAccountStatus.Active;
                    ads.adcreateddate    = DateTime.UtcNow;
                    ads.UserId           = userId;
                    ads.Verified         = AdsStatus.Verified;
                    ads.WebsiteUrl       = homePageUrl;
                    ads.EmailId          = mailId;
                    ads.Verifieddate     = DateTime.UtcNow.Date;
                    var savedStatus = dbr.Add(ads);

                    if (savedStatus != 1)
                    {
                        return(Ok("Ads found on website"));
                    }

                    lstUser.First().Adsstatus           = AdsStatus.Verified;
                    lstUser.First().TrailStatus         = UserTrailStatus.active;
                    lstUser.First().PaymentType         = PaymentType.paypal;
                    lstUser.First().PayPalAccountStatus = PayPalAccountStatus.added;
                    lstUser.First().AccountType         = SBAccountType.Standard;
                    lstUser.First().PaymentStatus       = SBPaymentStatus.Paid;
                    dbr.Update(lstUser.First());
                }

                return(Ok("Ads found on website"));
            }
            catch (Exception)
            {
                return(BadRequest("Something went wrong please try after sometime"));
            }
        }
Example #3
0
        public IActionResult AddAdsUrl(long userId, string url)
        {
            try
            {
                Domain.Socioboard.Models.AdsOffers ads = new AdsOffers();

                DatabaseRepository dbr          = new DatabaseRepository(_logger, _env);
                IList <AdsOffers>  lstAdsOffers = dbr.Find <AdsOffers>(t => t.UserId == userId);
                if (lstAdsOffers.Count == 0)
                {
                    Match match = Regex.Match(url, @"^(?:\w+://)?([^/?]*)");
                    //string domain = match.Groups[1].Value;
                    string            homepageurl = match.Value;
                    IList <AdsOffers> lstwebsites = dbr.Find <AdsOffers>(t => t.WebsiteUrl.Contains(homepageurl));
                    if (lstwebsites.Count == 0)
                    {
                        string lstcontent = Repositories.AdsOffersRepository.findUrlForAds(homepageurl);
                        //string lstcontents = Repositories.AdsOffersRepository.GetHomePage(url);
                        if (lstcontent == "Ads found on website")
                        {
                            IList <User> lstUser = dbr.Find <User>(t => t.Id == userId);
                            string       mailid  = lstUser.First().EmailId;
                            if (lstUser != null && lstUser.Count() > 0)
                            {
                                ads.adsaccountstatus = Domain.Socioboard.Enum.AdsOfferAccountStatus.Active;
                                ads.adcreateddate    = DateTime.UtcNow;
                                ads.UserId           = userId;
                                ads.Verified         = Domain.Socioboard.Enum.AdsStatus.Verified;
                                ads.WebsiteUrl       = homepageurl;
                                ads.EmailId          = mailid;
                                ads.Verifieddate     = DateTime.UtcNow.Date;
                                int SavedStatus = dbr.Add <Domain.Socioboard.Models.AdsOffers>(ads);
                                if (SavedStatus == 1)
                                {
                                    lstUser.First().Adsstatus           = Domain.Socioboard.Enum.AdsStatus.Verified;
                                    lstUser.First().TrailStatus         = Domain.Socioboard.Enum.UserTrailStatus.active;
                                    lstUser.First().PaymentType         = Domain.Socioboard.Enum.PaymentType.paypal;
                                    lstUser.First().PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added;
                                    lstUser.First().AccountType         = Domain.Socioboard.Enum.SBAccountType.Standard;
                                    lstUser.First().PaymentStatus       = Domain.Socioboard.Enum.SBPaymentStatus.Paid;
                                    //int SavedUserStatus = dbr.Add<Domain.Socioboard.Models.User>(user);
                                    int SavedUserStatus = dbr.Update <User>(lstUser.First());
                                    // int SavedUserStatus = dbr.Update<User>(user);
                                }
                            }
                            return(Ok("Ads found on website"));
                        }
                        else
                        {
                            return(BadRequest("Ads not found on website"));
                        }
                    }
                    else
                    {
                        return(BadRequest("website already register for this offer"));
                    }
                }
                else
                {
                    return(BadRequest("you already register for this offer"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Something went wrong please try after sometime"));
            }

            // return Ok();
        }