public async Task <IEnumerable <AppTypeHistoryModel> > GetAppTypeHistory(AppTypeHistoryModel model) { var logs = await _dbContext.RequestLogs.Where(x => x.AppTypeId == model.AppType.Id && x.Failed == false).OrderByDescending(x => x.Id).ToListAsync(); var result = logs.Select(x => new AppTypeHistoryModel { AppType = JsonConvert.DeserializeObject <AppTypeModel>(x.Body), LogId = x.Id, ProcessDuration = x.ProcessDuration, StartTime = x.StartTime, UserId = x.UserId }).ToList(); return(result); }
public async Task <IEnumerable <AppTypeHistoryModel> > GetDeletedAppTypeHistory(AppTypeHistoryModel model) { // TODO. THIS ACTION MAY BE SLOW WHEN REQUEST LOG TABLE WOULD BE LARGE var logs = await _dbContext.RequestLogs .Where(x => x.AppTypeId != null && x.Failed == false && PathChecker(x.Body, "DeleteAppType")).ToListAsync(); if (!logs.Any()) { return(new List <AppTypeHistoryModel>()); } var result = logs.Select(x => new AppTypeHistoryModel { AppType = JsonConvert.DeserializeObject <AppTypeModel>(x.Body), LogId = x.Id, ProcessDuration = x.ProcessDuration, StartTime = x.StartTime, UserId = x.UserId }).ToList(); return(result); }