public static ProfileHistoryViewModel Initialize(this ProfileHistoryViewModel model, Profile profile, ITimestampFormatter timestampFormatter)
        {
            model.UserLogin    = profile.Login;
            model.HistoryItems = profile.History
                                 .OrderByDescending(h => h.Timestamp)
                                 .Select(h => new ProfileHistoryItemViewModel().Initialize(h, timestampFormatter))
                                 .ToList();

            return(model);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> History(string login, string key)
        {
            var profile = await dbContext.Profiles
                          .Include(p => p.History).ThenInclude(h => h.Anime)
                          .Include(p => p.History).ThenInclude(h => h.Manga)
                          .Include(p => p.History).ThenInclude(h => h.UserList)
                          .FirstOrDefaultAsync(p => string.Equals(p.Login, login, StringComparison.OrdinalIgnoreCase));

            if (profile == null)
            {
                return(NotFound());
            }
            var model = new ProfileHistoryViewModel().Initialize(profile, timestampFormatter);

            return(View(model));
        }