/// <summary> /// Gets the weight associated with an <see cref="UsageEventType"/>. /// </summary> /// <param name="eventType">The event type to convert</param> /// <returns>The weight of the event</returns> public static float GetEventWeight(this UsageEventType eventType) { switch (eventType) { case UsageEventType.Click: return(1); case UsageEventType.RecommendationClick: return(2); case UsageEventType.AddShopCart: return(3); case UsageEventType.RemoveShopCart: return(-1); case UsageEventType.Purchase: return(4); default: return(1); } }
public static string DeleteEvent(int rowId, UsageEventType eventType) { try { lms_Entities db = new ClientDBEntities(); if (eventType == UsageEventType.SCORE) { Courses_Scores cs = db.Courses_Scores.Where(c => c.rowId == rowId).FirstOrDefault(); db.Courses_Scores.Remove(cs); } else { Courses_Usage cu = db.Courses_Usage.Where(c => c.rowId == rowId).FirstOrDefault(); db.Courses_Usage.Remove(cu); } db.SaveChanges(); return(JsonResponse.NoError); } catch (Exception ex) { return(JsonResponse.Error(ex)); } }