Exemplo n.º 1
0
        public NccMenu Update(NccMenu entity)
        {
            var oldEntity = _entityRepository.Query().Include("MenuItems").FirstOrDefault(x => x.Id == entity.Id);

            if (oldEntity != null)
            {
                RecursiveLoad(oldEntity);

                for (var i = 0; i < oldEntity.MenuItems.Count; i++)
                {
                    RecursiveNccMenuItemDelete(oldEntity.MenuItems[i]);
                }

                _menuItemRepository.SaveChange();

                oldEntity = _entityRepository.Query().Include("MenuItems").FirstOrDefault(x => x.Id == entity.Id);
                using (var txn = _entityRepository.BeginTransaction())
                {
                    CopyNewData(oldEntity, entity);
                    _entityRepository.Edit(oldEntity);
                    _entityRepository.SaveChange();
                    txn.Commit();
                }
            }

            return(entity);
        }
Exemplo n.º 2
0
        public override NccMenu Update(NccMenu entity)
        {
            var oldEntity = _entityRepository.Get(entity.Id);

            if (oldEntity != null)
            {
                RecursiveLoad(oldEntity);

                for (var i = 0; i < oldEntity.MenuItems.Count; i++)
                {
                    RecursiveNccMenuItemDelete(oldEntity.MenuItems[i]);
                }

                _menuItemRepository.SaveChange();

                oldEntity = _entityRepository.Get(entity.Id);
                using (var txn = _entityRepository.BeginTransaction())
                {
                    CopyNewData(entity, oldEntity);
                    _entityRepository.Edit(oldEntity);
                    _entityRepository.SaveChange();
                    txn.Commit();
                }
            }

            return(entity);
        }