public static StoryKick AddStoryKick(int storyID, int userID, int hostID, string ipAddress) { StoryKick storyKick = new StoryKick(); storyKick.StoryID = storyID; storyKick.UserID = userID; storyKick.HostID = hostID; storyKick.IPAddress = ipAddress; storyKick.Save(); return(storyKick); }
public static StoryKickCollection GetUserStoryKicks(int userID) { string cacheKey = String.Format("Kick_StoryKickTable_{0}", userID); CacheManager <string, StoryKickCollection> storyKickCache = GetStoryKickCache(); StoryKickCollection storyKicks = storyKickCache[cacheKey]; if (storyKicks == null) { //TODO: get the latest n kicks for this userIdentifier storyKicks = StoryKick.FetchByUserID(userID); storyKickCache.Insert(cacheKey, storyKicks, CacheHelper.CACHE_DURATION_IN_SECONDS, System.Web.Caching.CacheItemPriority.NotRemovable); } return(storyKicks); }
//TODO: GJ: some improvements are needed here - a sproc would be better //TODO: simone.busoli: no more sps, right? public static int KickStory(int storyID, int userID, int hostID, string ipAddress) { // If the user has already kicked the story return the current number of kicks // This may happen if the user has two browser windows opened on the same story and // tries to kick on both pages if (StoryBR.DoesStoryKickExist(storyID, userID, hostID)) { return(Story.FetchByID(storyID).KickCount); } StoryKick storyKick = StoryBR.AddStoryKick(storyID, userID, hostID, ipAddress); GetUserStoryKicks(userID).Add(storyKick); UserAction.RecordKick(hostID, GetUser(userID), Story.FetchByID(storyID)); return(StoryBR.IncrementKickCount(storyID)); }
public static void DeleteStoryKick(int storyID, int userID, int hostID) { StoryKick.Destroy(storyID, userID, hostID); }