Example #1
0
        public JsonResult AuditLog(VendorAuditLogCriteria criteria)
        {
            var page = _vendorAuditLogQueries.GetChanges(criteria);

            return Json(new
            {
                total = page.TotalPages,
                page = page.CurrentPage,
                records = page.TotalItems,
                rows = (from item in page.Items
                        select new
                        {
                            id = item.VendorId,
                            cell = new object[]
                                            {
                                                item.Field,
                                                item.OldValue,
                                                item.NewValue,
                                                item.Timestamp.ToShortDateString(),
                                                item.HistUserName,
                                                item.HistFullName,
                                                item.HistEmailAddress
                                            }
                        }).ToArray()

            });
        }
        public Page<VendorHistoryDetail> GetChanges(VendorAuditLogCriteria criteria)
        {
            var sql = Sql.Builder
               .OrderBy(criteria.OrderBy + " " + criteria.OrderByDirection)
               .Where("vendorId=@0", criteria.VendorId);

            if (criteria.Field.ToLower() != "all") sql.And("field=@0", criteria.Field);

            return _repository.PagedQuery<VendorHistoryDetail>(criteria.PageNumber, criteria.ItemsPerPage, sql.SQL, sql.Arguments);
        }