public ActionResult Details(int id) { SongViewModelWithMarks songViewModel = new SongViewModelWithMarks(); songViewModel.Marks = _markService.GetAllMarkEntities().ToMvcMark(); songViewModel.Songs = new List<Song>() {_songService.GetSongEntity(id).ToMvcSong()}; MvcUser user = _userService.GetByPredicate(u => u.Email == User.Identity.Name).ToMvcUser(); Mark mark = _userService.GetMark(user.Id, id).ToMvcMark(); if (mark != null) { songViewModel.Songs.First().Marks.Add(mark); } return View(songViewModel); }
public ActionResult Index() { MvcUser user = _userService.GetByPredicate(u => u.Email == User.Identity.Name).ToMvcUser(); SongViewModelWithMarks songViewModel = new SongViewModelWithMarks() { Marks = _markService.GetAllMarkEntities().ToMvcMark(), Songs = _songService.GetAllSongEntities().ToMvcSong() }; songViewModel.MarksId = new int[3]; foreach (Song song in songViewModel.Songs) { Mark mark = _userService.GetMark(user.Id, song.Id).ToMvcMark(); if (mark != null) { song.Marks.Add(mark); } } SetRating(songViewModel.Songs); return View(songViewModel); }