/// <summary> /// Populates a LogIndexViewModel by mapping the related objects to it. /// </summary> /// <param name="vm">View model to be mapped.</param> /// <param name="logItems">Array of LogItem objects to be mapped.</param> public static void MapToViewModel(this LogIndexViewModel vm, LogItem[] logItems) { for (var i = 0; i < logItems.Length; i++) { vm.LogItems.Add(new LogItemViewModel() { Date = logItems[i].Date.ToString("yyyy-MM-dd"), FileSizeKB = (logItems[i].FileSizeKB.HasValue) ? logItems[i].FileSizeKB.Value.ToString() : "0", FileName = logItems[i].FileName }); } }
public ActionResult PublishLogs() { LogIndexViewModel viewModel = new LogIndexViewModel(); LogItem[] logItems = _logManager.GetLogItems(); if (logItems != null) { viewModel.MapToViewModel(logItems); } return(View("~/Views/SPRK/Report/PublishLogs.cshtml", viewModel)); }
// GET: Log public ActionResult List(LogQuery formModel) { var eventsCollection = repository_.GetEvents(formModel); var sourceId = eventsCollection.Source; var snapshot = eventsCollection.Snapshot; var source = new LogSourceModel(sourceId, snapshot); var sources = repository_ .GetSources() .Select(id => new LogSourceModel(id, id == sourceId ? snapshot : null)) .ToList(); formModel.Source = new LogSourceInput(source, sources); var viewModel = new LogIndexViewModel { Query = formModel, Events = eventsCollection.Events }; return(View(viewModel)); }