public static bool AddContestEvent(ContestEvent contestEvent, int contestId) { using (var redisManager = new PooledRedisClientManager("[email protected]:9038")) { using (var client = redisManager.GetCacheClient()) { var contestEvents = client.Get<IList<ContestEvent>>(String.Format(selectContestEvents, contestId)); if (contestEvents != null) contestEvents.Add(contestEvent); return client.Set<IList<ContestEvent>>(String.Format(selectContestEvents, contestId), contestEvents); } } }
public static bool RemoveContestEvent(ContestEvent contestEvent, int contestId) { using (var redisManager = new PooledRedisClientManager("[email protected]:9038")) { using (var client = redisManager.GetCacheClient()) { var contestEvents = client.Get<IList<ContestEvent>>(String.Format(selectContestEvents, contestId)); if (contestEvents != null) { ContestEvent contestEventToRemove = contestEvents.FirstOrDefault(t => t.EventName.Equals(contestEvent.EventName)); contestEvents.Remove(contestEventToRemove); } return client.Set<IList<ContestEvent>>(String.Format(selectContestEvents, contestId), contestEvents); } } }