Beispiel #1
0
        public IActionResult Index()
        {
            var events = _eventData.GetEventsWithOrganizer();
            var model  = new List <EventViewModel>();

            foreach (var e in events)
            {
                model.Add(new EventViewModel
                {
                    Id     = e.Id,
                    Author = string.IsNullOrEmpty(e.Organizer.Name) || string.IsNullOrEmpty(e.Organizer.Surname)?
                             e.Organizer.UserName:$"{e.Organizer.Name} {e.Organizer.Surname}",
                    ImageUrl    = e.ImageUrl,
                    ReleaseTime = e.Time,
                    TextPreview = StringFormatter.FormatForPreview(e.Text),
                    Title       = e.Name,
                });
            }
            return(View(model));
        }