public static void TryToCreditAdAndReferrer(int adId, string IP, int referrerId) { var advert = new PaidToPromoteAdvert(adId); var pack = new PaidToPromotePack(advert.PackId); if (pack.Ends.EndMode == End.Mode.Clicks) { advert.CreditClicks(); } else { advert.CheckDays(); } try { if (advert.CreatorId != 1005) { var checkIPQuery = string.Format("SELECT COUNT(*) FROM {0} WHERE [IP] = '{1}' AND [CreditedUser] = {2}", PaidToPromoteTemporaryIP.TableName, IP, referrerId); var sessionCount = (int)TableHelper.SelectScalar(checkIPQuery); var newIPSession = new PaidToPromoteTemporaryIP { IP = IP, AdvertId = advert.Id }; if (sessionCount == 0) { CrfeditPTPUser(referrerId); newIPSession.CreditedUser = referrerId; } else { newIPSession.CreditedUser = null; } newIPSession.Save(); } } catch (Exception ex) { ErrorLogger.Log(ex); } }
public static int PackComparision(PaidToPromotePack x, PaidToPromotePack y) { if ((int)x.Ends.EndMode < (int)y.Ends.EndMode) { return(1); } else if ((int)x.Ends.EndMode == (int)y.Ends.EndMode) { if (x.Price > y.Price) { return(1); } if (x.Price == y.Price) { return(0); } return(-1); } return(-1); }