MockDataService.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using CasinosManager.Api.Domain;
  2. using CasinosManager.Api.Dto;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace CasinosManager.Api.Service
  6. {
  7. public class MockDataService
  8. {
  9. private static List<Student> _students;
  10. public List<Student> GetStudents()
  11. {
  12. if (_students == null)
  13. {
  14. _students = new List<Student>();
  15. Random random = new Random();
  16. for (var i = 0; i < 100; i++)
  17. {
  18. var student = new Student();
  19. student.Id = i + 1;
  20. student.Name = "test_" + student.Id;
  21. student.Age = random.Next(15, 24);
  22. student.Sex = random.Next(1, 10) % 2 == 0 ? "男" : "女";
  23. student.CreateTime = DateTime.Today.AddDays(-i);
  24. student.CreateTimeStr = student.CreateTime.ToString("yyyy-MM-dd");
  25. _students.Add(student);
  26. }
  27. }
  28. return _students;
  29. }
  30. public DashboardDto GetDashboard()
  31. {
  32. Random random = new Random();
  33. DashboardDto dashboard = new DashboardDto();
  34. dashboard.A = random.Next(60,100);
  35. dashboard.B = random.Next(100, 200);
  36. dashboard.C = random.Next(200, 500);
  37. dashboard.D = random.Next(500, 1000);
  38. dashboard.Consumes = new List<ConsumeModel>();
  39. for (var i = 10; i >= 0; i--)
  40. {
  41. dashboard.Consumes.Add(new ConsumeModel()
  42. {
  43. Date = DateTime.Now.AddDays(-i).ToString("yyyy-MM-dd"),
  44. Amount = random.Next(100, 500)
  45. });
  46. }
  47. return dashboard;
  48. }
  49. }
  50. }