public IActionResult Delete(Guid pageId, string routeName, [FromServices] IMemoryCache cache)
        {
            try
            {
                var response = _customPageService.DeletePage(pageId);
                if (response.IsSuccess)
                {
                    var cacheKey = $"page-{routeName.ToLower()}";
                    cache.Remove(cacheKey);

                    return(Json(pageId));
                }

                return(ServerError());
            }
            catch (Exception e)
            {
                Logger.LogError(e, $"Error Delete CustomPage, Id: {pageId}.");
                return(ServerError());
            }
        }
示例#2
0
        public IActionResult Delete(Guid pageId, string routeName, [FromServices] IMemoryCache cache)
        {
            try
            {
                var response = _customPageService.DeletePage(pageId);
                if (response.IsSuccess)
                {
                    var cacheKey = $"page-{routeName.ToLower()}";
                    cache.Remove(cacheKey);

                    Logger.LogInformation($"User '{User.Identity.Name}' deleted custom page id: '{pageId}', {nameof(routeName)}: '{routeName}'");

                    return(Json(pageId));
                }

                return(ServerError());
            }
            catch (Exception e)
            {
                Logger.LogError(e, $"Error Delete CustomPage, Id: {pageId}.");
                return(ServerError());
            }
        }
        public async Task <IActionResult> Delete(Guid pageId, string routeName, [FromServices] IMemoryCache cache)
        {
            try
            {
                var response = _customPageService.DeletePage(pageId);
                if (response.IsSuccess)
                {
                    var cacheKey = $"page-{routeName.ToLower()}";
                    cache.Remove(cacheKey);

                    Logger.LogInformation($"User '{User.Identity.Name}' deleted custom page id: '{pageId}', {nameof(routeName)}: '{routeName}'");
                    await _moongladeAudit.AddAuditEntry(EventType.Content, EventId.PageDeleted, $"Page '{pageId}' deleted.");

                    return(Json(pageId));
                }

                return(ServerError());
            }
            catch (Exception e)
            {
                Logger.LogError(e, $"Error Delete CustomPage, Id: {pageId}.");
                return(ServerError());
            }
        }