示例#1
0
        public void PreSavingDataProcessing(bool isNew)
        {
            var testDate = DateTime.Now;

            if (!isNew)
            {
                _contentCategory.CreateDate = testDate;
            }

            Thread.Sleep(1000);
            _contentCategoryManageService.PreSavingDataProcessing(_contentCategory);

            switch (isNew)
            {
            case true:
                Assert.Greater(_contentCategory.CreateDate, testDate);
                Assert.IsNull(_contentCategory.LastModification);
                break;

            case false:
                Assert.AreEqual(_contentCategory.CreateDate, testDate);
                Assert.Greater(_contentCategory.LastModification, testDate);
                break;
            }
        }
示例#2
0
        public void SaveContentCategory(ContentCategory contentCategory)
        {
            using (var context = new ApplicationDbContext())
            {
                _categoryManageService.PreSavingDataProcessing(contentCategory);

                context.ContentCategories.AddOrUpdate(contentCategory);

                context.SaveChanges();
            }
        }