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); }
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)); }
public ActionResult View(RollbackModel request) { request.Ready(); return(View("view", new EcardModelItem <RollbackModel>(request))); }