ViewModel.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ModelExam
  7. {
  8. /// <summary>
  9. /// Работа и взаимодействие с ViewModel
  10. /// </summary>
  11. class ViewModel
  12. {
  13. public List<users> user;
  14. public void User()
  15. {
  16. user = Newuser();
  17. }
  18. public List<users> Newuser()
  19. {
  20. List<users> allusers = new List<users>();
  21. List<users> bdusers = Base.entities.users.ToList();
  22. users buff;
  23. foreach (var users in bdusers)
  24. {
  25. buff = new users();
  26. buff.id = users.id;
  27. buff.surname = users.surname;
  28. buff.firstname = users.firstname;
  29. buff.patronymic = users.patronymic;
  30. buff.id_post = users.id_post;
  31. buff.email = users.email;
  32. buff.password = users.password;
  33. posts post = Base.entities.posts.FirstOrDefault(x => x.id == users.id);
  34. // buff.idpost = post.title;
  35. allusers.Add(buff);
  36. }
  37. return allusers;
  38. }
  39. public class Usersmetrics
  40. {
  41. public List<usersmetrics> um = new List<usersmetrics>();
  42. public void Usersmetric()
  43. {
  44. um = Usermetric();
  45. }
  46. public List<usersmetrics> Usermetric()
  47. {
  48. List<usersmetrics> allusersmetrics = new List<usersmetrics>();
  49. List<usersmetrics> bdusersmetrics = Base.entities.usersmetrics.ToList();
  50. usersmetrics buff;
  51. foreach (var users in bdusersmetrics)
  52. {
  53. buff = new usersmetrics();
  54. buff.id = users.id;
  55. buff.id_user = users.id_user;
  56. buff.id_metric = users.id_metric;
  57. buff.coefficient = users.coefficient;
  58. buff.dateofachievement = users.dateofachievement;
  59. users usermetrics = Base.entities.users.FirstOrDefault(x => x.id == users.id_metric);
  60. buff.id_metric = usermetrics.id;//.title;
  61. metrics met = Base.entities.metrics.FirstOrDefault(x => x.id == users.id_metric);
  62. //buff.metrics = met.metric;//.title;
  63. allusersmetrics.Add(buff);
  64. }
  65. return allusersmetrics;
  66. }
  67. }
  68. }
  69. }