コード例 #1
0
        public BllFilepathLib Create(BllFilepathLib entity)
        {
            var ormLib = uow.FilepathLibs.CreateAndReturnOrm(mapper.MapToDal(entity));

            uow.Commit();
            entity.Id = ormLib.id;
            FilepathMapper EntityMapper = new FilepathMapper(uow);

            foreach (var Entity in entity.Entities)
            {
                var dalEntity = EntityMapper.MapToDal(Entity);
                dalEntity.Lib_id = entity.Id;
                var ormEntity = uow.Filepaths.CreateAndReturnOrm(dalEntity);
                uow.Commit();
                Entity.Id = ormEntity.id;
            }
            return(entity);
        }
コード例 #2
0
        public BllFilepathLib Update(BllFilepathLib entity)
        {
            FilepathMapper EntityMapper = new FilepathMapper();

            foreach (var Entity in entity.Entities)
            {
                var dalEntity = EntityMapper.MapToDal(Entity);
                dalEntity.Lib_id = entity.Id;
                if (Entity.Id == 0)
                {
                    var ormEntity = uow.Filepaths.CreateAndReturnOrm(dalEntity);
                    uow.Commit();
                    Entity.Id = ormEntity.id;
                }
                else
                {
                    uow.Filepaths.Update(dalEntity);
                }
            }

            var EntitysWithLibId = ((IGetterByLibId <DalFilepath>)uow.Filepaths).GetEntitiesByLibId(entity.Id);

            foreach (var Entity in EntitysWithLibId)
            {
                bool isTrashEntity = true;
                foreach (var item in entity.Entities)
                {
                    if (item.Id == Entity.Id)
                    {
                        isTrashEntity = false;
                        break;
                    }
                }
                if (isTrashEntity == true)
                {
                    uow.Filepaths.Delete(Entity.Id);
                }
            }
            uow.Commit();

            return(entity);
        }