Exemplo n.º 1
0
        /// <summary>
        /// Deletes the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        public void Delete(StaticTextCRUDModel item)
        {
            var staticText = SessionFactory <StaticText> .Load(item.Id);

            staticText.Hidden = true;
            SessionFactory <StaticText> .Store(staticText);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Created item.</returns>
        public StaticTextCRUDModel Create(StaticTextCRUDModel item)
        {
            var staticText = new StaticText
            {
                Id                 = Guid.NewGuid(),
                Title              = item.Title,
                FriendlyUrl        = item.FriendlyUrl,
                CreatedDate        = item.ChangeDate,
                Modified           = item.ChangeDate,
                PublishDate        = item.PublishDate,
                Description        = item.Description,
                CreatedBy          = (User)item.Creator,
                AreCommentAllowed  = item.AllowComments,
                ActualVersion      = 0,
                StaticTextVersions = new List <StaticTextVersion>()
                {
                    new StaticTextVersion
                    {
                        CreatedDate = item.ChangeDate,
                        CreatedBy   = (User)item.Creator,
                        Text        = item.Text,
                        Version     = 0
                    }
                }
            };

            SessionFactory <StaticText> .Store(staticText);

            // assign id
            item.Id = staticText.Id;

            return(item);
        }
Exemplo n.º 3
0
        public ActionResult Create(StaticTextCRUDModel model)
        {
            if (ModelState.IsValid)
            {
                var crudOperations = RepositoryFactory.Command<IStaticTextCrud>();

                if (string.IsNullOrWhiteSpace(model.FriendlyUrl))
                {
                    model.FriendlyUrl = model.Title;
                }

                model.FriendlyUrl = GenerateUniqueFriendlyUrl(model.FriendlyUrl, Guid.Empty);
                model.ChangeDate = DateTime.Now;
                model.Creator = ((UserPrincipal)User).User;
                model.Description = GenerateDescription(model.Text);

                using (var tran = RepositoryFactory.StartTransaction(IoC.Resolve<SearchUpdateContext>()))
                {
                    RepositoryFactory.Command<IStaticTextCrud>().Create(model);
                    tran.Commit();
                    RepositoryFactory.Command<ISearchCommands>().IndexStaticText(tran, model);
                }
                return RedirectToActionWithAjax("Index");

            }
            return ViewWithAjax(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Updated item.</returns>
        public StaticTextCRUDModel Update(StaticTextCRUDModel item)
        {
            var staticText = SessionFactory <StaticText> .Load(item.Id);

            if (string.IsNullOrEmpty(item.FriendlyUrl))
            {
                item.FriendlyUrl = item.Title;
            }

            staticText.Title             = item.Title;
            staticText.FriendlyUrl       = item.FriendlyUrl;
            staticText.Modified          = item.ChangeDate;
            staticText.PublishDate       = item.PublishDate;
            staticText.CreatedBy         = (User)item.Creator;
            staticText.AreCommentAllowed = item.AllowComments;
            staticText.ActualVersion     = staticText.StaticTextVersions.Count;

            staticText.Description = item.Description;

            staticText.StaticTextVersions.Add(
                new StaticTextVersion
            {
                CreatedDate = item.ChangeDate,
                CreatedBy   = (User)item.Creator,
                Text        = item.Text,
                Version     = staticText.ActualVersion
            }
                );

            SessionFactory <StaticText> .Store(staticText);

            return(item);
        }
Exemplo n.º 5
0
        public ActionResult Create(StaticTextCRUDModel model)
        {
            if (ModelState.IsValid)
            {
                var crudOperations = RepositoryFactory.Action <IStaticTextCrud>();

                if (string.IsNullOrWhiteSpace(model.FriendlyUrl))
                {
                    model.FriendlyUrl = model.Title;
                }

                model.FriendlyUrl = GenerateUniqueFriendlyUrl(model.FriendlyUrl, Guid.Empty);
                model.ChangeDate  = DateTime.Now;
                model.Creator     = RepositoryFactory.Action <IUserAction>().GetByName(UserInfo.Name);
                model.Description = GenerateDescription(model.Text);

                using (var tran = RepositoryFactory.StartTransaction(IoC.Resolve <SearchUpdateContext>()))
                {
                    RepositoryFactory.Action <IStaticTextCrud>().Create(model);
                    tran.Commit();
                    RepositoryFactory.Action <ISearchAction>().IndexStaticText(tran, model);
                }
                return(RedirectToActionWithAjax("Index"));
            }
            return(ViewWithAjax(model));
        }
Exemplo n.º 6
0
        public void Test_delete()
        {
            using (RepositoryFactory.StartUnitOfWork())
            {
                var item = new StaticTextCRUDModel()
                {
                    Creator       = _user,
                    ChangeDate    = new DateTime(2002, 1, 1),
                    PublishDate   = new DateTime(2002, 2, 1),
                    AllowComments = true,
                    Title         = "updateable new",
                    Text          = "updateable new content"
                };

                var crudActions            = RepositoryFactory.GetRepository <StaticText>().GetAction <IStaticTextCrud>();
                var dataActions            = RepositoryFactory.GetRepository <StaticText>().GetAction <IStaticTextData>();
                var initialStaticTextCount = dataActions.GetAll().Count();

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Create(item);
                    tran.Commit();
                }

                WaitForIndexing();

                // check created item
                var storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);

                Assert.AreEqual(initialStaticTextCount + 1, dataActions.GetAll().Count());

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    crudActions.Delete(item);
                    tran.Commit();
                }

                WaitForIndexing();

                Assert.AreEqual(initialStaticTextCount, dataActions.GetAll().Count());
            }
        }
Exemplo n.º 7
0
        public ActionResult Edit(StaticTextCRUDModel model)
        {
            if (ModelState.IsValid)
            {
                var crudOperations = RepositoryFactory.Action <IStaticTextCrud>();

                // get original item to test change permissions
                var originalItem = crudOperations.FindByPk(model.Id);

                if (originalItem != null)
                {
                    if (originalItem.Creator.Name == UserInfo.Name ||
                        UserInfo.IsAdmin())
                    {
                        if (string.IsNullOrWhiteSpace(model.FriendlyUrl))
                        {
                            model.FriendlyUrl = model.Title;
                        }

                        model.FriendlyUrl = GenerateUniqueFriendlyUrl(model.FriendlyUrl, model.Id);
                        model.ChangeDate  = DateTime.Now;
                        model.Creator     = RepositoryFactory.Action <IUserAction>().GetByName(UserInfo.Name);
                        model.Description = GenerateDescription(model.Text);

                        using (var tran = RepositoryFactory.StartTransaction(IoC.Resolve <SearchUpdateContext>()))
                        {
                            RepositoryFactory.Action <IStaticTextCrud>().Update(model);
                            tran.Commit();
                            RepositoryFactory.Action <ISearchAction>().DeleteFromIndex(tran, model.Id.ToString());
                            RepositoryFactory.Action <ISearchAction>().IndexStaticText(tran, model);
                        }
                        return(RedirectToActionWithAjax("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ModelResources.NotAllowedToChangeError);
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, ModelResources.ItemNotExistsError);
                }
            }
            return(ViewWithAjax(model));
        }
Exemplo n.º 8
0
        public ActionResult Delete(StaticTextCRUDModel model)
        {
            var item = RepositoryFactory.Action <IStaticTextCrud>().FindByPk(model.Id);

            if (item.Creator.Name == UserInfo.Name ||
                UserInfo.IsAdmin())
            {
                using (var tran = RepositoryFactory.StartTransaction(IoC.Resolve <SearchUpdateContext>()))
                {
                    RepositoryFactory.Action <IStaticTextCrud>().Delete(model);
                    tran.Commit();
                    RepositoryFactory.Action <ISearchAction>().DeleteFromIndex(tran, model.Id.ToString());
                }
                return(RedirectToActionWithAjax("Index"));
            }
            ModelState.AddModelError(string.Empty, ModelResources.NotAllowedToDeleteError);

            return(ViewWithAjax(model));
        }
Exemplo n.º 9
0
        public void Test_create()
        {
            using (RepositoryFactory.StartUnitOfWork())
            {
                var item = new StaticTextCRUDModel()
                {
                    Creator       = _user,
                    ChangeDate    = new DateTime(2002, 1, 1),
                    PublishDate   = new DateTime(2002, 2, 1),
                    AllowComments = true,
                    Title         = "čreate new",
                    Description   = "description new",
                    FriendlyUrl   = "create-new",
                    Text          = "create new content"
                };

                var crudActions = RepositoryFactory.GetRepository <StaticText>().GetAction <IStaticTextCrud>();

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Create(item);
                    tran.Commit();
                }

                Assert.AreEqual("create-new", item.FriendlyUrl);

                var storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(item.FriendlyUrl, storedItem.FriendlyUrl);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Indexes the static text.
        /// </summary>
        /// <param name="transaction">The transaction.</param>
        /// <param name="staticText">The static text.</param>
        public void IndexStaticText(ITransaction transaction, StaticTextCRUDModel staticText)
        {
            SearchUpdateContext tranContext = transaction.TransactionContext as SearchUpdateContext;

            if (tranContext == null)
            {
                throw new Exception("SearchUpdateContext not part of ITransaction!");
            }

            Document doc = new Document();

            doc.Add(new Field(SearchResult.IdField, staticText.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field(SearchResult.TypeField, SearchResult.StaticTextType, Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Title", staticText.Title, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Text", RemoveTags(staticText.Text), Field.Store.NO, Field.Index.ANALYZED));
            doc.Add(new Field("Published", DateTools.DateToString(staticText.PublishDate, DateTools.Resolution.SECOND), Field.Store.NO, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Date", DateTools.DateToString(staticText.ChangeDate, DateTools.Resolution.SECOND), Field.Store.NO, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("User", staticText.Creator.Name, Field.Store.NO, Field.Index.ANALYZED));

            doc.SetBoost(5F);

            tranContext.IndexWriter.AddDocument(doc);
        }
Exemplo n.º 11
0
        public virtual void Test_update()
        {
            using (RepositoryFactory.StartUnitOfWork())
            {
                var item = new StaticTextCRUDModel()
                {
                    Creator = _user,
                    ChangeDate = new DateTime(2002, 1, 1),
                    PublishDate = new DateTime(2002, 2, 1),
                    AllowComments = true,
                    Title = "text",
                    FriendlyUrl = "text_update",
                    Text = "updateable new content",
                    Description = "description update"
                };

                var crudActions = RepositoryFactory.GetRepository<StaticText>().GetCommand<IStaticTextCrud>();

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Create(item);
                    tran.Commit();
                }

                // check created item
                var storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(item.FriendlyUrl, storedItem.FriendlyUrl);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);

                // change item
                item.Text = "updateable new content - change 1";
                item.Description = "updated description update";
                item.ChangeDate = new DateTime(2002, 2, 1);

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Update(item);
                    tran.Commit();
                }

                // check changed item
                storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(item.FriendlyUrl, storedItem.FriendlyUrl);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);

                // change item
                item.Text = "updateable new content - change 2";
                item.ChangeDate = new DateTime(2002, 3, 1);

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Update(item);
                    tran.Commit();
                }

                // check changed item
                storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);

                // check if there are 3 items in history
                var staticText = TestProvider.GetById<StaticText>(item.Id);
                Assert.AreEqual(3, staticText.StaticTextVersions.Count);
                Assert.AreEqual(new DateTime(2002, 1, 1), staticText.StaticTextVersions[0].CreatedDate);
                Assert.AreEqual("updateable new content", staticText.StaticTextVersions[0].Text);
                Assert.AreEqual(new DateTime(2002, 2, 1), staticText.StaticTextVersions[1].CreatedDate);
                Assert.AreEqual("updateable new content - change 1", staticText.StaticTextVersions[1].Text);
                Assert.AreEqual(new DateTime(2002, 3, 1), staticText.StaticTextVersions[2].CreatedDate);
                Assert.AreEqual("updateable new content - change 2", staticText.StaticTextVersions[2].Text);
            }
        }
Exemplo n.º 12
0
        public virtual void Test_delete()
        {
            using (RepositoryFactory.StartUnitOfWork())
            {

                var item = new StaticTextCRUDModel()
                               {
                                   Creator = _user,
                                   ChangeDate = new DateTime(2002, 1, 1),
                                   PublishDate = new DateTime(2002, 2, 1),
                                   AllowComments = true,
                                   Title = "updateable new",
                                   Text = "updateable new content"
                               };

                var crudActions = RepositoryFactory.GetRepository<StaticText>().GetCommand<IStaticTextCrud>();
                var dataActions = RepositoryFactory.GetRepository<StaticText>().GetCommand<IStaticTextData>();
                var initialStaticTextCount = dataActions.GetAll().Count();

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Create(item);
                    tran.Commit();
                }

                TestProvider.WaitForIndexing();

                // check created item
                var storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);

                Assert.AreEqual(initialStaticTextCount + 1, dataActions.GetAll().Count());

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    crudActions.Delete(item);
                    tran.Commit();
                }

                TestProvider.WaitForIndexing();

                Assert.AreEqual(initialStaticTextCount, dataActions.GetAll().Count());
            }
        }
Exemplo n.º 13
0
        public virtual void Test_create()
        {
            using (RepositoryFactory.StartUnitOfWork())
            {
                var item = new StaticTextCRUDModel()
                               {
                                   Creator = _user,
                                   ChangeDate = new DateTime(2002, 1, 1),
                                   PublishDate = new DateTime(2002, 2, 1),
                                   AllowComments = true,
                                   Title = "čreate new",
                                   Description = "description new",
                                   FriendlyUrl = "create-new",
                                   Text = "create new content"
                               };

                var crudActions = RepositoryFactory.GetRepository<StaticText>().GetCommand<IStaticTextCrud>();

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Create(item);
                    tran.Commit();
                }

                Assert.AreEqual("create-new", item.FriendlyUrl);

                var storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(item.FriendlyUrl, storedItem.FriendlyUrl);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);
            }
        }
Exemplo n.º 14
0
        public ActionResult Delete(StaticTextCRUDModel model)
        {
            var item = RepositoryFactory.Command<IStaticTextCrud>().FindByPk(model.Id);
            if (item.Creator.Name == CurrentUser.Name
                || ((UserPrincipal)User).IsAdmin())
            {
                using (var tran = RepositoryFactory.StartTransaction(IoC.Resolve<SearchUpdateContext>()))
                {
                    RepositoryFactory.Command<IStaticTextCrud>().Delete(model);
                    tran.Commit();
                    RepositoryFactory.Command<ISearchCommands>().DeleteFromIndex(tran, model.Id.ToString());
                }
                return RedirectToActionWithAjax("Index");
            }
            ModelState.AddModelError(string.Empty, ModelResources.NotAllowedToDeleteError);

            return ViewWithAjax(model);
        }
Exemplo n.º 15
0
        public ActionResult Edit(StaticTextCRUDModel model)
        {
            if (ModelState.IsValid)
            {
                var crudOperations = RepositoryFactory.Command<IStaticTextCrud>();

                // get original item to test change permissions
                var originalItem = crudOperations.FindByPk(model.Id);

                if (originalItem != null)
                {
                    if (originalItem.Creator.Name == CurrentUser.Name
                        || CurrentUser.IsAdmin())
                    {

                        if (string.IsNullOrWhiteSpace(model.FriendlyUrl))
                        {
                            model.FriendlyUrl = model.Title;
                        }

                        model.FriendlyUrl = GenerateUniqueFriendlyUrl(model.FriendlyUrl, model.Id);
                        model.ChangeDate = DateTime.Now;
                        model.Creator = ((UserPrincipal)User).User;
                        model.Description = GenerateDescription(model.Text);

                        using (var tran = RepositoryFactory.StartTransaction(IoC.Resolve<SearchUpdateContext>()))
                        {
                            RepositoryFactory.Command<IStaticTextCrud>().Update(model);
                            tran.Commit();
                            RepositoryFactory.Command<ISearchCommands>().DeleteFromIndex(tran, model.Id.ToString());
                            RepositoryFactory.Command<ISearchCommands>().IndexStaticText(tran, model);
                        }
                        return RedirectToActionWithAjax("Index");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ModelResources.NotAllowedToChangeError);
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, ModelResources.ItemNotExistsError);
                }
            }
            return ViewWithAjax(model);
        }
Exemplo n.º 16
0
        public void Test_update()
        {
            using (RepositoryFactory.StartUnitOfWork())
            {
                var item = new StaticTextCRUDModel()
                {
                    Creator       = _user,
                    ChangeDate    = new DateTime(2002, 1, 1),
                    PublishDate   = new DateTime(2002, 2, 1),
                    AllowComments = true,
                    Title         = "text",
                    FriendlyUrl   = "text_update",
                    Text          = "updateable new content",
                    Description   = "description update"
                };

                var crudActions = RepositoryFactory.GetRepository <StaticText>().GetAction <IStaticTextCrud>();

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Create(item);
                    tran.Commit();
                }

                // check created item
                var storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(item.FriendlyUrl, storedItem.FriendlyUrl);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);

                // change item
                item.Text        = "updateable new content - change 1";
                item.Description = "updated description update";
                item.ChangeDate  = new DateTime(2002, 2, 1);

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Update(item);
                    tran.Commit();
                }

                // check changed item
                storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(item.FriendlyUrl, storedItem.FriendlyUrl);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);

                // change item
                item.Text       = "updateable new content - change 2";
                item.ChangeDate = new DateTime(2002, 3, 1);

                using (var tran = RepositoryFactory.StartTransaction())
                {
                    item = crudActions.Update(item);
                    tran.Commit();
                }

                // check changed item
                storedItem = crudActions.FindByPk(item.Id);

                Assert.AreEqual(item.Id, storedItem.Id);
                Assert.AreEqual(((User)item.Creator).Id, ((User)storedItem.Creator).Id);
                Assert.AreEqual(item.ChangeDate, storedItem.ChangeDate);
                Assert.AreEqual(item.PublishDate, storedItem.PublishDate);
                Assert.AreEqual(item.AllowComments, storedItem.AllowComments);
                Assert.AreEqual(item.Title, storedItem.Title);
                Assert.AreEqual(item.Text, storedItem.Text);
                Assert.AreEqual(item.Description, storedItem.Description);

                // check if there are 3 items in history
                var staticText = SessionFactory <StaticText> .Load(item.Id);

                Assert.AreEqual(3, staticText.StaticTextVersions.Count);
                Assert.AreEqual(new DateTime(2002, 1, 1), staticText.StaticTextVersions[0].CreatedDate);
                Assert.AreEqual("updateable new content", staticText.StaticTextVersions[0].Text);
                Assert.AreEqual(new DateTime(2002, 2, 1), staticText.StaticTextVersions[1].CreatedDate);
                Assert.AreEqual("updateable new content - change 1", staticText.StaticTextVersions[1].Text);
                Assert.AreEqual(new DateTime(2002, 3, 1), staticText.StaticTextVersions[2].CreatedDate);
                Assert.AreEqual("updateable new content - change 2", staticText.StaticTextVersions[2].Text);
            }
        }