Пример #1
0
        public virtual ActionResult Rollback(HiveId id)
        {
            var model = new RollbackModel { Id = id };

            using (var uow = Hive.Create<IContentStore>())
            {
                var entity = uow.Repositories.Revisions.GetLatestRevision<TypedEntity>(model.Id);
                if (entity == null)
                    throw new NullReferenceException("Could not find entity with id " + model.Id);

                model.LastRevision = entity;

                var nameAttr = model.LastRevision.Item.Attributes.FirstOrDefault(x => x.AttributeDefinition.Alias == NodeNameAttributeDefinition.AliasValue);
                model.Name = nameAttr != null ? nameAttr.GetValueAsString("Name") : "Unknown";
                model.CreateDate = model.LastRevision.Item.UtcStatusChanged.DateTime;

                var revisions = uow.Repositories.Revisions.GetAll<TypedEntity>(model.LastRevision.Item.Id);

                model.Versions = revisions
                    .OrderByDescending(x => x.MetaData.UtcStatusChanged)
                    .Skip(1) // Skip current revision
                    .Select(x =>
                        {
                            var name = x.MetaData.StatusType.Name.IfNull(y => new LocalizedString(x.MetaData.StatusType.Alias));

                            return new SelectListItem
                                         {
                                             Text = x.MetaData.UtcCreated.DateTime.ToShortDateString() + " " + x.MetaData.UtcCreated.DateTime.ToShortTimeString() + " - '" + name + "'", 
                                             Value = x.MetaData.Id.ToString()
                                         };
                        });
            }

            return View(model);
        }
Пример #2
0
        public virtual ActionResult Rollback(HiveId id)
        {
            var model = new RollbackModel {
                Id = id
            };

            using (var uow = Hive.Create <IContentStore>())
            {
                var entity = uow.Repositories.Revisions.GetLatestRevision <TypedEntity>(model.Id);
                if (entity == null)
                {
                    throw new NullReferenceException("Could not find entity with id " + model.Id);
                }

                model.LastRevision = entity;

                var nameAttr = model.LastRevision.Item.Attributes.FirstOrDefault(x => x.AttributeDefinition.Alias == NodeNameAttributeDefinition.AliasValue);
                model.Name = nameAttr != null?nameAttr.GetValueAsString("Name") : "Unknown";

                model.CreateDate = model.LastRevision.Item.UtcStatusChanged.DateTime;

                var revisions = uow.Repositories.Revisions.GetAll <TypedEntity>(model.LastRevision.Item.Id);

                model.Versions = revisions
                                 .OrderByDescending(x => x.MetaData.UtcStatusChanged)
                                 .Skip(1) // Skip current revision
                                 .Select(x =>
                {
                    var name = x.MetaData.StatusType.Name.IfNull(y => new LocalizedString(x.MetaData.StatusType.Alias));

                    return(new SelectListItem
                    {
                        Text = x.MetaData.UtcCreated.DateTime.ToShortDateString() + " " + x.MetaData.UtcCreated.DateTime.ToShortTimeString() + " - '" + name + "'",
                        Value = x.MetaData.Id.ToString()
                    });
                });
            }

            return(View(model));
        }
Пример #3
0
 public ActionResult View(RollbackModel request)
 {
     request.Ready();
     return(View("view", new EcardModelItem <RollbackModel>(request)));
 }