/// <summary>
        /// Saves the customErrorPageItem internal.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="customErrorPageItemId">The customErrorPageItem id.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        private ItemContext <CustomErrorPageItemViewModel> SaveCustomErrorPageItemInternal(ItemContext <CustomErrorPageItemViewModel> context, string customErrorPageItemId, string provider)
        {
            var manager = CustomErrorPagesManager.GetManager(provider);
            var id      = new Guid(customErrorPageItemId);

            CustomErrorPageItem customErrorPageItem = null;

            if (id == Guid.Empty)
            {
                customErrorPageItem = manager.CreateCustomErrorPageItem();
            }
            else
            {
                customErrorPageItem = manager.GetCustomErrorPageItem(id);
            }

            CustomErrorPageItemsViewModelTranslator.ToModel(context.Item, customErrorPageItem, manager);

            if (id != Guid.Empty)
            {
                manager.UpdateCustomErrorPageItem(customErrorPageItem);
            }

            manager.SaveChanges();
            CustomErrorPageItemsViewModelTranslator.ToViewModel(customErrorPageItem, context.Item, manager);
            return(context);
        }
        /// <summary>
        /// Deletes the customErrorPageItem internal.
        /// </summary>
        /// <param name="customErrorPageItemId">The customErrorPageItem id.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        private bool DeleteCustomErrorPageItemInternal(string customErrorPageItemId, string provider)
        {
            var manager = CustomErrorPagesManager.GetManager(provider);

            manager.DeleteCustomErrorPageItem(manager.GetCustomErrorPageItem(new Guid(customErrorPageItemId)));
            manager.SaveChanges();

            return(true);
        }
        /// <summary>
        /// Batches the delete customErrorPageItems internal.
        /// </summary>
        /// <param name="ids">The ids.</param>
        /// <param name="provider">The provider.</param>
        /// <returns></returns>
        private bool BatchDeleteCustomErrorPageItemsInternal(string[] ids, string provider)
        {
            var manager = CustomErrorPagesManager.GetManager(provider);

            foreach (var stringId in ids)
            {
                var customErrorPageItemId = new Guid(stringId);
                manager.DeleteCustomErrorPageItem(manager.GetCustomErrorPageItem(customErrorPageItemId));
            }
            manager.SaveChanges();

            return(true);
        }
        /// <summary>
        /// Gets the customErrorPageItem internal.
        /// </summary>
        /// <param name="customErrorPageItemId">The customErrorPageItem id.</param>
        /// <returns></returns>
        private ItemContext <CustomErrorPageItemViewModel> GetCustomErrorPageItemInternal(string customErrorPageItemId)
        {
            var customErrorPageItemIdGuid = new Guid(customErrorPageItemId);
            var manager = CustomErrorPagesManager.GetManager();

            var customErrorPageItem          = manager.GetCustomErrorPageItem(customErrorPageItemIdGuid);
            var customErrorPageItemViewModel = new CustomErrorPageItemViewModel();

            CustomErrorPageItemsViewModelTranslator.ToViewModel(customErrorPageItem, customErrorPageItemViewModel, manager);

            return(new ItemContext <CustomErrorPageItemViewModel>()
            {
                Item = customErrorPageItemViewModel
            });
        }
        /// <summary>
        /// Gets the customErrorPageItems internal.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="sortExpression">The sort expression.</param>
        /// <param name="skip">The skip.</param>
        /// <param name="take">The take.</param>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        private CollectionContext <CustomErrorPageItemViewModel> GetCustomErrorPageItemsInternal(string provider, string sortExpression, int skip, int take, string filter)
        {
            var manager = CustomErrorPagesManager.GetManager(provider);
            var customErrorPageItems = manager.GetCustomErrorPageItems();

            var totalCount = customErrorPageItems.Count();

            if (!string.IsNullOrEmpty(sortExpression))
            {
                customErrorPageItems = customErrorPageItems.OrderBy(sortExpression);
            }

            if (!string.IsNullOrEmpty(filter))
            {
                customErrorPageItems = customErrorPageItems.Where(filter);
            }

            if (skip > 0)
            {
                customErrorPageItems = customErrorPageItems.Skip(skip);
            }

            if (take > 0)
            {
                customErrorPageItems = customErrorPageItems.Take(take);
            }

            var customErrorPageItemsList = new List <CustomErrorPageItemViewModel>();

            foreach (var customErrorPageItem in customErrorPageItems)
            {
                var customErrorPageItemViewModel = new CustomErrorPageItemViewModel();
                CustomErrorPageItemsViewModelTranslator.ToViewModel(customErrorPageItem, customErrorPageItemViewModel, manager);
                customErrorPageItemsList.Add(customErrorPageItemViewModel);
            }

            return(new CollectionContext <CustomErrorPageItemViewModel>(customErrorPageItemsList)
            {
                TotalCount = totalCount
            });
        }
        /// <summary>
        /// Translates CustomErrorPageItem to CustomErrorPageItem view model.
        /// </summary>
        /// <param name="source">
        /// An instance of the <see cref="CustomErrorPageItem"/>.
        /// </param>
        /// <param name="target">
        /// An instance of the <see cref="CustomErrorPageItemViewModel"/>.
        /// </param>
        public static void ToViewModel(CustomErrorPageItem source, CustomErrorPageItemViewModel target, CustomErrorPagesManager manager)
        {
            target.Id           = source.Id;
            target.LastModified = source.LastModified;
            target.DateCreated  = source.DateCreated;

            target.StatusCode = source.StatusCode;
            target.PageId     = source.PageId;
        }
 /// <summary>
 /// Translates CustomErrorPageItem view model to CustomErrorPageItem model.
 /// </summary>
 /// <param name="source">
 /// An instance of the <see cref="CustomErrorPageItemViewModel"/>.
 /// </param>
 /// <param name="target">
 /// An instance of the <see cref="CustomErrorPageItem"/>.
 /// </param>
 public static void ToModel(CustomErrorPageItemViewModel source, CustomErrorPageItem target, CustomErrorPagesManager manager)
 {
     target.StatusCode = source.StatusCode;
     target.PageId     = source.PageId;
 }