public void TestGetNameShouldReturnEmptyIfColumnIsNull()
        {
            _viewModel = new LayoutItemViewModel(null);
            var result = _viewModel.Name;

            Assert.That(result, Is.Empty);
        }
 public void SetUp()
 {
     _columnDto = new ColumnDto {
         Name = "Test"
     };
     _viewModel = new LayoutItemViewModel(_columnDto);
 }
Beispiel #3
0
        public LayoutItemViewModel Copy(ApiCall call)
        {
            var sitedb = call.WebSite.SiteDb();

            var layout = sitedb.Layouts.Get(call.ObjectId);

            if (layout != null)
            {
                var newlayout = Lib.Serializer.Copy.DeepCopy <Layout>(layout);
                newlayout.CreationDate = DateTime.UtcNow;
                newlayout.LastModified = DateTime.UtcNow;

                newlayout.Name = call.GetValue("name");
                sitedb.Layouts.AddOrUpdate(newlayout, call.Context.User.Id);

                int storenamehash = Lib.Security.Hash.ComputeInt(call.WebSite.SiteDb().Layouts.StoreName);

                LayoutItemViewModel model = new LayoutItemViewModel();
                model.Id            = newlayout.Id;
                model.Name          = newlayout.Name;
                model.KeyHash       = Sites.Service.LogService.GetKeyHash(newlayout.Id);
                model.StoreNameHash = storenamehash;
                model.LastModified  = newlayout.LastModified;
                model.Relations     = Sites.Helper.RelationHelper.Sum(sitedb.Layouts.GetUsedBy(newlayout.Id));

                return(model);
            }
            return(null);
        }
        public void TestSetSelectedColumnShouldSetSelectedColumn()
        {
            var viewModel = new LayoutItemViewModel(_columnDto);

            _viewModel.SelectedColumn = viewModel;
            _mockMessageBus.Verify(p => p.Execute(It.Is <SetXAxisColumnCommand>(q => q.Id == 1)), Times.Once());
        }
Beispiel #5
0
        private LayoutItemViewModel GetSelectedColumnViewModel()
        {
            var columnDto = _messageBus.Execute(new GetLinkColumnQuery());

            if (columnDto == null)
            {
                return(null);
            }

            var viewModel = new LayoutItemViewModel(columnDto);

            return(viewModel);
        }
Beispiel #6
0
        private void SetSelectedColumnViewModel(LayoutItemViewModel value)
        {
            if (value == null)
            {
                return;
            }

            if (value.Column == null)
            {
                _messageBus.Execute(new UnsetLinkColumnCommand());
            }
            else
            {
                _messageBus.Execute(new SetLinkColumnCommand(value.Column.Id));
            }
        }
Beispiel #7
0
        public override List <object> List(ApiCall call)
        {
            List <LayoutItemViewModel> result = new List <LayoutItemViewModel>();

            var sitedb = call.WebSite.SiteDb();

            int storenamehash = Lib.Security.Hash.ComputeInt(sitedb.Layouts.StoreName);

            foreach (var item in sitedb.Layouts.All())
            {
                LayoutItemViewModel model = new LayoutItemViewModel();
                model.Id            = item.Id;
                model.Name          = item.Name;
                model.KeyHash       = Sites.Service.LogService.GetKeyHash(item.Id);
                model.StoreNameHash = storenamehash;
                model.LastModified  = item.LastModified;
                model.Relations     = Sites.Helper.RelationHelper.Sum(sitedb.Layouts.GetUsedBy(item.Id));
                result.Add(model);
            }
            return(result.ToList <object>());
        }