public static List <Contest> GetActiveContestsForMember(ContestType Type, Member User) { var ActiveContests = GetActiveContests(Type); var BlockedContestsForMember = TableHelper.SelectRows <ContestsBlocked>(TableHelper.MakeDictionary("UserId", User.Id)); var resultList = new List <Contest>(); foreach (var active in ActiveContests) { bool IsOk = true; foreach (var blocked in BlockedContestsForMember) { if (blocked.ContestId == active.Id) { IsOk = false; } } if (UsersBannedFromContestsType.IsBannedFromContestType(User.Id, Type)) { IsOk = false; } if (IsOk) { resultList.Add(active); } } return(resultList); }
public static void SaveBan(int userId, ContestType contestType) { var contestsTypestable = new UsersBannedFromContestsType(); contestsTypestable.UserId = userId; contestsTypestable.Type = contestType; contestsTypestable.Save(); }
public bool CanMemberParticipate(Member User, bool obeyParticipateCheck = false) { int numberOfReferrals = 0; //1. check if he is not already participating if (obeyParticipateCheck == false && IsMemberParticipating(User.Name, true)) { return(false); } //2. Check requirements if (User.TotalClicks < this.ClicksRestriction) { return(false); } if (User.Registered > DateTime.Now.AddDays(-this.RegisteredDaysRestriction)) { return(false); } if (this.DirectRefRestriction > 0 && User.GetDirectReferralsCount() < this.DirectRefRestriction) { return(false); } if (this.RentedRefRestriction > 0) { var rrm = new RentReferralsSystem(User.Name, User.Membership); if (rrm.GetUserRentedReferralsCount() < this.RentedRefRestriction) { return(false); } } //3. Check blacklist var BlockedContestsForMember = TableHelper.SelectRows <ContestsBlocked>(TableHelper.MakeDictionary("UserId", User.Id)); foreach (var elem in BlockedContestsForMember) { if (elem.ContestId == this.Id) { return(false); } } if (UsersBannedFromContestsType.IsBannedFromContestType(this.Id, this.Type)) { return(false); } return(true); }
public static bool IsBannedFromContestType(int userId, ContestType contestType) { var BlockedContestTypes = UsersBannedFromContestsType.Get(userId); foreach (var BlockedContestType in BlockedContestTypes) { if (BlockedContestType.Type == contestType) { return(true); } } return(false); }