Ejemplo n.º 1
0
        List <Expression <Func <AuditTrail, bool> > > GetSearchExpression(AuditTrailFilterDto model)
        {
            List <Expression <Func <AuditTrail, bool> > > filterList = new List <Expression <Func <AuditTrail, bool> > >();


            if (!string.IsNullOrEmpty(model.UserName))
            {
                filterList.Add(c => c.UserName.Contains(model.UserName));
            }

            if (!string.IsNullOrEmpty(model.Audit_ActionCode))
            {
                filterList.Add(c => c.Audit_ActionCode.Contains(model.Audit_ActionCode));
            }

            if (!string.IsNullOrEmpty(model.EntityName))
            {
                filterList.Add(c => c.EntityName.Contains(model.EntityName));
            }

            if (model.FromDate != null)
            {
                filterList.Add(c => c.Date.Date >= model.FromDate);
            }

            if (model.ToDate != null)
            {
                filterList.Add(c => c.Date.Date <= model.ToDate);
            }

            return(filterList);
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> OnPostSearch(AuditTrailFilterDto model)
        {
            try
            {
                model = await AuditTrailService.Search(model);

                return(new JsonResult(new { Result = CommonConstants.JTableConstants.OK, Records = model.Items, TotalRecordCount = model.TotalCount }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { Result = CommonConstants.JTableConstants.ERROR, ex.Message }));
            }
        }
Ejemplo n.º 3
0
        public async Task <AuditTrailFilterDto> Search(AuditTrailFilterDto model)
        {
            var expression = GetSearchExpression(model);

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

            model.Items = query.Select(auditTrail => AuditTrailMapper.MapToDto(auditTrail)).ToList();

            model.TotalCount = totalCount;

            return(model);
        }