|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | + |
| 4 | +namespace InsightLearn.WebAssembly.Models.Admin |
| 5 | +{ |
| 6 | + /// <summary> |
| 7 | + /// Analytics overview with KPIs and trend data for the Analytics admin page |
| 8 | + /// </summary> |
| 9 | + public class AnalyticsOverviewModel |
| 10 | + { |
| 11 | + // User Metrics |
| 12 | + public int TotalUsers { get; set; } |
| 13 | + public TrendDataModel UsersTrend { get; set; } = new(); |
| 14 | + |
| 15 | + // Course Metrics |
| 16 | + public int TotalCourses { get; set; } |
| 17 | + public int PublishedCourses { get; set; } |
| 18 | + public int DraftCourses { get; set; } |
| 19 | + public TrendDataModel CoursesTrend { get; set; } = new(); |
| 20 | + |
| 21 | + // Enrollment Metrics |
| 22 | + public int TotalEnrollments { get; set; } |
| 23 | + public int ActiveEnrollments { get; set; } |
| 24 | + public int CompletedEnrollments { get; set; } |
| 25 | + public TrendDataModel EnrollmentsTrend { get; set; } = new(); |
| 26 | + |
| 27 | + // Revenue Metrics |
| 28 | + public decimal TotalRevenue { get; set; } |
| 29 | + public TrendDataModel RevenueTrend { get; set; } = new(); |
| 30 | + |
| 31 | + // Metadata |
| 32 | + public DateTime GeneratedAt { get; set; } |
| 33 | + public string DateRange { get; set; } = string.Empty; |
| 34 | + } |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Trend data with percentage change and direction indicator |
| 38 | + /// </summary> |
| 39 | + public class TrendDataModel |
| 40 | + { |
| 41 | + public decimal PercentageChange { get; set; } // e.g., 12.5 for +12.5% |
| 42 | + public bool IsPositive { get; set; } |
| 43 | + public string Description { get; set; } = "vs previous period"; |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// User growth data point for chart |
| 48 | + /// </summary> |
| 49 | + public class UserGrowthDataPoint |
| 50 | + { |
| 51 | + public DateTime Date { get; set; } |
| 52 | + public string Label { get; set; } = string.Empty; // e.g., "Nov 1" |
| 53 | + public int NewUsers { get; set; } |
| 54 | + public int TotalUsers { get; set; } |
| 55 | + } |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Revenue data point for chart |
| 59 | + /// </summary> |
| 60 | + public class RevenueDataPoint |
| 61 | + { |
| 62 | + public DateTime Date { get; set; } |
| 63 | + public string Label { get; set; } = string.Empty; // e.g., "Nov 2024" |
| 64 | + public decimal Revenue { get; set; } |
| 65 | + public int Transactions { get; set; } |
| 66 | + } |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Top performing course data |
| 70 | + /// </summary> |
| 71 | + public class TopCourseModel |
| 72 | + { |
| 73 | + public int Rank { get; set; } |
| 74 | + public Guid CourseId { get; set; } |
| 75 | + public string CourseName { get; set; } = string.Empty; |
| 76 | + public string CategoryName { get; set; } = string.Empty; |
| 77 | + public int TotalEnrollments { get; set; } |
| 78 | + public decimal TotalRevenue { get; set; } |
| 79 | + public decimal AverageRating { get; set; } |
| 80 | + public int ReviewCount { get; set; } |
| 81 | + } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// Category distribution data for pie/bar chart |
| 85 | + /// </summary> |
| 86 | + public class CategoryDistributionModel |
| 87 | + { |
| 88 | + public Guid CategoryId { get; set; } |
| 89 | + public string CategoryName { get; set; } = string.Empty; |
| 90 | + public int CourseCount { get; set; } |
| 91 | + public int EnrollmentCount { get; set; } |
| 92 | + public decimal Revenue { get; set; } |
| 93 | + public decimal Percentage { get; set; } // Percentage of total |
| 94 | + public string Color { get; set; } = string.Empty; // Hex color for chart |
| 95 | + } |
| 96 | + |
| 97 | + /// <summary> |
| 98 | + /// Date range options for analytics filtering |
| 99 | + /// </summary> |
| 100 | + public enum DateRangeOption |
| 101 | + { |
| 102 | + SevenDays, |
| 103 | + ThirtyDays, |
| 104 | + NinetyDays, |
| 105 | + OneYear, |
| 106 | + ThisMonth, |
| 107 | + Last3Months, |
| 108 | + Last6Months, |
| 109 | + ThisYear, |
| 110 | + Custom |
| 111 | + } |
| 112 | + |
| 113 | + /// <summary> |
| 114 | + /// Request model for analytics with date range |
| 115 | + /// </summary> |
| 116 | + public class AnalyticsRequest |
| 117 | + { |
| 118 | + public DateRangeOption RangeOption { get; set; } = DateRangeOption.ThirtyDays; |
| 119 | + public DateTime? StartDate { get; set; } |
| 120 | + public DateTime? EndDate { get; set; } |
| 121 | + } |
| 122 | + |
| 123 | + /// <summary> |
| 124 | + /// Analytics overview response from API |
| 125 | + /// </summary> |
| 126 | + public class AnalyticsOverviewResponse |
| 127 | + { |
| 128 | + public int TotalUsers { get; set; } |
| 129 | + public int TotalCourses { get; set; } |
| 130 | + public int TotalEnrollments { get; set; } |
| 131 | + public decimal TotalRevenue { get; set; } |
| 132 | + public double UserGrowthPercent { get; set; } |
| 133 | + public double CourseGrowthPercent { get; set; } |
| 134 | + public double EnrollmentGrowthPercent { get; set; } |
| 135 | + public double RevenueGrowthPercent { get; set; } |
| 136 | + public DateTime GeneratedAt { get; set; } |
| 137 | + } |
| 138 | + |
| 139 | + /// <summary> |
| 140 | + /// User growth chart data response |
| 141 | + /// </summary> |
| 142 | + public class UserGrowthDataResponse |
| 143 | + { |
| 144 | + public List<ChartDataPointModel> Data { get; set; } = new(); |
| 145 | + public int TotalNewUsers { get; set; } |
| 146 | + public double AverageDaily { get; set; } |
| 147 | + } |
| 148 | + |
| 149 | + /// <summary> |
| 150 | + /// Revenue trends chart data response |
| 151 | + /// </summary> |
| 152 | + public class RevenueTrendResponse |
| 153 | + { |
| 154 | + public List<ChartDataPointModel> Data { get; set; } = new(); |
| 155 | + public decimal TotalPeriodRevenue { get; set; } |
| 156 | + public decimal AverageDaily { get; set; } |
| 157 | + } |
| 158 | + |
| 159 | + /// <summary> |
| 160 | + /// Enrollment trends chart data response |
| 161 | + /// </summary> |
| 162 | + public class EnrollmentTrendResponse |
| 163 | + { |
| 164 | + public List<ChartDataPointModel> Data { get; set; } = new(); |
| 165 | + public int TotalPeriodEnrollments { get; set; } |
| 166 | + public double AverageDaily { get; set; } |
| 167 | + } |
| 168 | + |
| 169 | + /// <summary> |
| 170 | + /// Top courses response from API |
| 171 | + /// </summary> |
| 172 | + public class TopCoursesResponse |
| 173 | + { |
| 174 | + public List<TopCourseItem> Courses { get; set; } = new(); |
| 175 | + public DateTime GeneratedAt { get; set; } |
| 176 | + } |
| 177 | + |
| 178 | + /// <summary> |
| 179 | + /// Individual top course item |
| 180 | + /// </summary> |
| 181 | + public class TopCourseItem |
| 182 | + { |
| 183 | + public Guid Id { get; set; } |
| 184 | + public string Title { get; set; } = string.Empty; |
| 185 | + public string InstructorName { get; set; } = string.Empty; |
| 186 | + public string CategoryName { get; set; } = string.Empty; |
| 187 | + public int EnrollmentCount { get; set; } |
| 188 | + public decimal Revenue { get; set; } |
| 189 | + public double Rating { get; set; } |
| 190 | + public int ReviewCount { get; set; } |
| 191 | + } |
| 192 | + |
| 193 | + /// <summary> |
| 194 | + /// Generic chart data point for all chart types |
| 195 | + /// </summary> |
| 196 | + public class ChartDataPointModel |
| 197 | + { |
| 198 | + public string Label { get; set; } = string.Empty; |
| 199 | + public decimal Value { get; set; } |
| 200 | + public DateTime? Date { get; set; } |
| 201 | + } |
| 202 | +} |
0 commit comments