public PageLayout GetPageLayout(Guid layoutId)
        {
            var resultLayout = _layoutRepository.GetLayout(layoutId);
            var result       = ConvertToPageLayout(resultLayout);

            return(result);
        }
Example #2
0
        public IActionResult Delete(Guid id)
        {
            try
            {
                var layout = _layoutRepository.GetLayout(id);

                if (layout != null)
                {
                    if (layout.IsDeleted)
                    {
                        bool result = _layoutRepository.DeleteLayout(id);
                        if (result)
                        {
                            return(Ok());
                        }
                    }
                    else
                    {
                        layout.IsDeleted = true;
                        var result = _layoutRepository.UpdateLayout(layout);
                        if (result != null)
                        {
                            return(Ok(result));
                        }
                    }
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("Error occured while deleting the layout"), ex);
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
 private static void AssertLayout(ILayoutRepository repository, string name, int expectedStations, int expectedTrackStretches, int expectedTimetableStretches)
 {
     var layout = repository.GetLayout(name);
     Assert.IsNotNull(layout);
     Assert.AreEqual(expectedStations, layout.Stations.Count(), "Fel antal stationer.");
     Assert.AreEqual(expectedTrackStretches, layout.TrackStretches.Count(), "Fel antal spårsträckor.");
     Assert.AreEqual(expectedTimetableStretches, layout.TimetableStretches.Count(), "Fel antal tidtabellsträckor.");
 }
Example #4
0
        public async Task <IAdminResult> Restore(RecycleItem item)
        {
            if (item == null)
            {
                return(null);
            }

            object resultItem = null;

            switch (item.RecycleItemType.Name)
            {
            case "Layouts":
                var layout = _layoutRepository.GetLayout(item.Id);
                layout.IsActive = true;
                resultItem      = _layoutRepository.UpdateLayout(layout);
                break;

            case "Page":
                var page = _pageRepository.GetPage(item.Id);
                page.IsActive = true;
                resultItem    = _pageRepository.UpdatePageActiveAndLayout(page);
                break;

            case "PageContent":
                resultItem = _pageContentRepository.RestorePageContent(item.Id);
                break;

            case "PageModule":
                var pageModule = _pageRepository.GetPageModule(item.Id);
                pageModule.IsActive = true;
                resultItem          = _pageRepository.UpdatePageModule(pageModule);
                break;
            }
            ;

            //_pageRepository.DeletePage();
            if (resultItem != null)
            {
                return(await Task.FromResult(new AdminResult(resultItem)
                {
                    IsSucceeded = true,
                    SuccessMessage = $"{item.RecycleItemType.Name} has been restored"
                }));
            }

            return(await Task.FromResult(new AdminResult(resultItem)
            {
                IsSucceeded = false,
                SuccessMessage = $"Unable to restore {item.RecycleItemType.Name}"
            }));
        }
Example #5
0
 public PageLayout GetPageLayout(Guid layoutId)
 {
     try
     {
         var        resultLayout = _layoutRepository.GetLayout(layoutId);
         PageLayout result       = ConvertToPageLayout(resultLayout);
         return(result);
     }
     catch (Exception ex)
     {
         _logger.LogError(string.Format("Error occured while getting oage layout: {0}", layoutId), ex);
     }
     return(null);
 }
Example #6
0
 public Layout GetLayout(System.Int32 LayoutId)
 {
     return(_iLayoutRepository.GetLayout(LayoutId));
 }