Пример #1
0
        public IActionResult Latest(int num = 10)
        {
            var sampleCharacters = new List <CharacterViewModel>();

            // add a bunch of sample Characterzes
            for (int i = 1; i <= num; i++)
            {
                sampleCharacters.Add(new CharacterViewModel()
                {
                    Id               = i,
                    Name             = String.Format("Sample Character {0}", i),
                    Sex              = RNG.Dice(2) == 0 ? Sex.Male : Sex.Female,
                    CreatedDate      = DateTime.Now,
                    LastModifiedDate = DateTime.Now
                });
            }

            // output the result in JSON format
            return(new JsonResult(
                       sampleCharacters,
                       new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented
            }));
        }