Ejemplo n.º 1
0
        public ActionResult ListLogs() {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageActivityLog))
                return AccessDeniedView();

            var activityLogSearchModel = new ActivityLogSearchModel();
            activityLogSearchModel.ActivityLogType.Add(new SelectListItem {
                Value = "0",
                Text = "All"
            });


            foreach (var at in _activityLogService.GetAllActivityTypes()) {
                activityLogSearchModel.ActivityLogType.Add(new SelectListItem {
                    Value = at.Id.ToString(),
                    Text = at.Name
                });
            }
            return View(activityLogSearchModel);
        }
Ejemplo n.º 2
0
        public ActionResult ListLogs(DataSourceRequest command, ActivityLogSearchModel model) {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageActivityLog))
                return AccessDeniedView();

            DateTime? startDateValue = (model.CreatedOnFrom == null) ? null
                : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, _dateTimeHelper.DefaultStoreTimeZone);

            DateTime? endDateValue = (model.CreatedOnTo == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.DefaultStoreTimeZone).AddDays(1);

            var activityLog = _activityLogService.GetAllActivities(startDateValue, endDateValue, null, model.ActivityLogTypeId, command.Page - 1, command.PageSize);
            var gridModel = new DataSourceResult {
                Data = activityLog.Select(x => {
                    var m = x.ToModel();
                    m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc);
                    return m;

                }),
                Total = activityLog.TotalCount
            };
            return Json(gridModel);
        }