Guest User

Untitled

a guest
Jul 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. [HttpGet]
  2. public ActionResult TestNew(string branchname)
  3. {
  4. // check stuff like permissions
  5. var db = new MovieContext();
  6. var model = new Model();
  7.  
  8.  
  9. var students = db.Student
  10. .Where(x => x.BranchName == branchname)
  11. .GroupBy(x => new { x.BranchName, x.Name, x.Currency, x.NoCart, x.NoAccount })
  12. .Select(x => new
  13. {
  14. BranchName = x.FirstOrDefault().BranchName,
  15. Name = x.FirstOrDefault().Name,
  16. A_Status = x.Max(p => p.A_Status),
  17. Currency = x.FirstOrDefault().Currency,
  18. NoCart = x.FirstOrDefault().NoCart,
  19. NoAccount = x.FirstOrDefault().NoAccount
  20. }).ToList();
  21. foreach (var item in students)
  22. {
  23. model.Students.Add(new Student
  24. {
  25. A_Status = item.A_Status,
  26. BranchName = item.BranchName,
  27. Name = item.Name,
  28. NoAccount = item.NoAccount,
  29. NoCart = item.NoCart,
  30. Currency = item.Currency
  31.  
  32. });
  33. }
  34. return View(model);
Add Comment
Please, Sign In to add comment