/// <summary> /// Tracks the specific quest for the current user /// </summary> /// <param name="id">The id of the quest</param> /// <returns>True if succesful, false otherwise</returns> public Boolean Track(int id) { if (!WebSecurity.IsAuthenticated) { return(false); } // Get the quest, then the tracking (if it exists) quest_template quest = _dbContext.quest_template.Find(id); if (quest == null) { return(false); } Boolean alreadyTracking = (from t in _dbContext.quest_tracking where t.quest_id == quest.id && t.user_id == WebSecurity.CurrentUserId select t).Any(); if (alreadyTracking) { return(false); } // Add a new tracking quest_tracking tracking = new quest_tracking() { quest_id = quest.id, user_id = WebSecurity.CurrentUserId }; _dbContext.quest_tracking.Add(tracking); _dbContext.SaveChanges(); return(true); }
/// <summary> /// Tracks the specific quest for the current user /// </summary> /// <param name="id">The id of the quest</param> /// <returns>True if succesful, false otherwise</returns> public Boolean Track(int id) { if (!WebSecurity.IsAuthenticated) return false; // Get the quest, then the tracking (if it exists) quest_template quest = _dbContext.quest_template.Find(id); if (quest == null) return false; Boolean alreadyTracking = (from t in _dbContext.quest_tracking where t.quest_id == quest.id && t.user_id == WebSecurity.CurrentUserId select t).Any(); if (alreadyTracking) return false; // Add a new tracking quest_tracking tracking = new quest_tracking() { quest_id = quest.id, user_id = WebSecurity.CurrentUserId }; _dbContext.quest_tracking.Add(tracking); _dbContext.SaveChanges(); return true; }