Exemple #1
0
        public OperationResult Update(ModuleModel model)
        {
            var entity = new Module
            {
                Id         = model.Id,
                Name       = model.Name,
                Code       = model.Code,
                ParentId   = model.ParentId != 0 ? model.ParentId : null,
                LinkUrl    = model.LinkUrl,
                Area       = model.Area,
                Controller = model.Controller,
                Action     = model.Action,
                OrderSort  = model.OrderSort,
                Icon       = model.Icon != null ? model.Icon : "",
                Enabled    = model.Enabled,
                IsMenu     = model.IsMenu,
                CreateId   = model.CreateId,
                CreateBy   = model.CreateBy,
                CreateTime = DateTime.Now,
                ModifyId   = model.ModifyId,
                ModifyBy   = model.ModifyBy,
                ModifyTime = DateTime.Now
            };

            ModuleRepository.Update(entity);
            return(new OperationResult(OperationResultType.Success, "更新成功"));
        }
Exemple #2
0
        public OperationResult Delete(int Id)
        {
            var model = Modules.FirstOrDefault(t => t.Id == Id);

            model.IsDeleted = true;
            ModuleRepository.Update(model);
            return(new OperationResult(OperationResultType.Success, "删除成功"));
        }
        public void Should_update_module()
        {
            const string newModuleTitle = "New Title 1";

            var moduleToUpdate = ModuleFactory.Module(_siteId, _moduleTypeId1, _moduleId1, newModuleTitle);

            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository = new ModuleRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                repository.Update(moduleToUpdate);
            }

            using (var context = new WeapsyDbContext(_contextOptions))
            {
                var repository    = new ModuleRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var updatedModule = repository.GetById(_moduleId1);

                Assert.AreEqual(newModuleTitle, updatedModule.Title);
            }
        }
Exemple #4
0
        public void TestTrackingEdit()
        {
           
            var moduleRep = new ModuleRepository();
            //var module = moduleRep.FindSingle(u => u.Id == 14);
            //module.CascadeId = DateTime.Now.ToShortTimeString();
            //如果不加u.Id !=7 则会造成异常,可理解为数据库的默认隔离级别为“读已提交”,不允许脏读!
            //var obstruct = moduleRep.Find(u =>u.Id != 7); 
            //foreach (var module1 in obstruct)
            //{
            //    module.CascadeId += module1.CascadeId;
            //}
            //moduleRep.Update(module);

            var module2 = new Module
            {
                Id = 14,
                CascadeId = DateTime.Now.ToShortTimeString()
            };
            moduleRep.Update(module2);
        }
        public void TestTrackingEdit()
        {
            var moduleRep = new ModuleRepository();

            //var module = moduleRep.FindSingle(u => u.Id == 14);
            //module.CascadeId = DateTime.Now.ToShortTimeString();
            //如果不加u.Id !=7 则会造成异常,可理解为数据库的默认隔离级别为“读已提交”,不允许脏读!
            //var obstruct = moduleRep.Find(u =>u.Id != 7);
            //foreach (var module1 in obstruct)
            //{
            //    module.CascadeId += module1.CascadeId;
            //}
            //moduleRep.Update(module);


            moduleRep.Update(u => u.Id, new Module
            {
                Id        = 15,
                Name      = "test",
                CascadeId = DateTime.Now.ToShortTimeString(),
                Url       = "ssss"
            });
        }