Beispiel #1
0
 /// <summary> Save data to the ErrorLog table in the DB </summary>
 /// <param name="dto"> The object containing the value </param>
 public bool Log(LoggingDTO dto)
 {
     if (ValidateData(dto))
     {
         try
         {
             ErrorLog model = new ErrorLogMapper().MapDtoToModel(dto);
             _context.ErrorLog.Add(model);
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
     else
     {
         try
         {
             _context.ErrorLog.Add(new ErrorLog
             {
                 AppLocation      = "ErrorLogRepository - Log()",
                 DateOccurred     = DateTime.Now,
                 DeveloperComment = "An error could not be logged because at least one required field was missing."
             });
         }
         catch (Exception)
         {
         }
     }
     return(false);
 }
Beispiel #2
0
        public async Task <ErrorLogFilterDto> Search(ErrorLogFilterDto model)
        {
            var expression = GetSearchExpression(model);

            (var query, int totalCount) = await AuditUnitOfWork.ErrorLogRepository.GetPagedByFiltersAsync(
                model.PageNumber,
                model.jtPageSize.Value,
                expression,
                a => a.OrderByDescending(d => d.Date));

            model.Items = query.Select(errorLog => ErrorLogMapper.MapToDto(errorLog)).ToList();

            model.TotalCount = totalCount;

            return(model);
        }