ViewModel.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Data.Entity;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Met_Fam
  9. {
  10. public partial class Goods
  11. {
  12. private string typeOfGoods;
  13. public string TypeOfGoods
  14. {
  15. get { return typeOfGoods; }
  16. set { typeOfGoods = value; }
  17. }
  18. }
  19. public partial class Goods
  20. {
  21. private int countfForBuing = 1;
  22. public int CountfForBuing
  23. {
  24. get { return countfForBuing; }
  25. set { countfForBuing = value; }
  26. }
  27. }
  28. public class Product
  29. {
  30. public List<Goods> gds;
  31. public Product()
  32. {
  33. gds = product();
  34. }
  35. public List<Goods> product()
  36. {
  37. List<Goods> goods = new List<Goods>();
  38. Goods buff;
  39. List<Goods> bdgoods = DataBase.BaseModel.Goods.ToList();
  40. foreach (Goods good in bdgoods)
  41. {
  42. buff = new Goods();
  43. buff.ID_Goods = good.ID_Goods;
  44. buff.Title_Goods = good.Title_Goods;
  45. buff.Price_Goods = good.Price_Goods;
  46. buff.Buying_Goods = good.Buying_Goods;
  47. buff.Picture = good.Picture;
  48. buff.Description = good.Description;
  49. buff.ID_Type_Goods = good.ID_Type_Goods;
  50. Type_Goods type_Goods = DataBase.BaseModel.Type_Goods.FirstOrDefault(x => x.ID_Type_Goods == good.ID_Type_Goods);
  51. buff.TypeOfGoods = type_Goods.Title_Type_Goods;
  52. goods.Add(buff);
  53. }
  54. return goods;
  55. }
  56. }
  57. public class Users
  58. {
  59. public List<User> usr;
  60. public Users()
  61. {
  62. usr = newuser();
  63. }
  64. public List<User> newuser()
  65. {
  66. List<User> users = new List<User>();
  67. User buff;
  68. List<User> bdusers = DataBase.BaseModel.User.ToList();
  69. foreach (User user in bdusers)
  70. {
  71. buff = new User();
  72. buff.ID_User = user.ID_User;
  73. buff.Surname_User = user.Surname_User;
  74. buff.Name_User = user.Name_User;
  75. buff.Login_User = user.Login_User;
  76. buff.Password_User = user.Password_User;
  77. buff.Phone_User = user.Phone_User;
  78. buff.Address = user.Address;
  79. buff.ID_Role = user.ID_Role;
  80. users.Add(buff);
  81. }
  82. return users;
  83. }
  84. }
  85. public class Video
  86. {
  87. public List<Videos> videos;
  88. List<int> buingVM;
  89. public Video(List<int> buing)
  90. {
  91. buingVM = buing;
  92. videos = newvideo();
  93. }
  94. public List<Videos> newvideo()
  95. {
  96. List<Videos> video = new List<Videos>();
  97. Videos buff;
  98. List<Videos> bdvideos = DataBase.BaseModel.Videos.ToList();
  99. foreach (Videos vid in bdvideos)
  100. {
  101. buff = new Videos();
  102. buff.ID_Video = vid.ID_Video;
  103. buff.Video = vid.Video;
  104. buff.ID_User = vid.ID_User;
  105. buff.ID_Goods = vid.ID_Goods;
  106. foreach (int i in buingVM)
  107. {
  108. if (i == buff.ID_Goods)
  109. {
  110. video.Add(buff);
  111. }
  112. }
  113. }
  114. return video;
  115. }
  116. }
  117. public class BGoods
  118. {
  119. public List<Buying_Goods> bg;
  120. public BGoods()
  121. {
  122. bg = newvideo();
  123. }
  124. public List<Buying_Goods> newvideo()
  125. {
  126. List<Buying_Goods> bgood = new List<Buying_Goods>();
  127. Buying_Goods buff;
  128. List<Buying_Goods> bdvideos = DataBase.BaseModel.Buying_Goods.ToList();
  129. foreach (Buying_Goods vid in bdvideos)
  130. {
  131. buff = new Buying_Goods();
  132. buff.ID_Buying_Goods = vid.ID_Buying_Goods;
  133. buff.ID_Goods = vid.ID_Goods;
  134. buff.ID_User = vid.ID_User;
  135. buff.Data_Buying_Goods = vid.Data_Buying_Goods;
  136. buff.Quantity = vid.Quantity;
  137. bgood.Add(buff);
  138. }
  139. return bgood;
  140. }
  141. }
  142. }