Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 public NccMenu Save(NccMenu entity)
 {
     _entityRepository.Add(entity);
     _entityRepository.SaveChange();
     return(entity);
 }