public static async Task <List <T> > GetDataSample <T>(IMongoService <T> ms) { var file = $"{Startup.PATH}/Data/{typeof(T).Name}_SEED.json"; if (File.Exists(file)) { try { var documents = JsonSerializer.Deserialize <List <T> >(File.ReadAllText(file)); // write var data = await ms.GetDocumentsAsync(); if (data.ToList().Any() == false) { foreach (T document in documents) // prevent others { await ms.AddDocumentAsync(document); } } return(documents); } catch (Exception exception) { Trace.WriteLine($"Exception: {exception.Message}"); } } return(new List <T>()); }
// GET: Sqs public async Task <ActionResult> Index() { var queueAttributes = await _sqsService.GetQueueDetailsAsync(); var logRecords = await _mongoService.GetDocumentsAsync(); queueAttributes.Logs = logRecords .Select(lr => new LogRecord { Id = lr.Id, Message = lr.Message, Version = lr.Version }).ToList(); return(View(queueAttributes)); }
public async Task <IEnumerable <Book> > Get() { return(await _ms.GetDocumentsAsync()); }