public void testDefaultAndNonDefaultConstructor() { IEntityB entity = EntityFactory.CreateEntity <IEntityB>(); Assert.AssertNotNull(entity); ConstructorInfo[] declaredConstructors = entity.GetType().GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); Assert.AssertEquals(1, declaredConstructors.Length); ConstructorInfo defaultConstructor = declaredConstructors[0]; Assert.AssertEquals(0, defaultConstructor.GetParameters().Length); }
public EntityBDto EntityMapping(IEntityB entityB) { // Comprobamos el parámetro de entrada. Guard.ArgumentIsNotNull( entityB, string.Format( Inflexion2.Resources.Framework.MapperErrorEntityNull, "Entity B") // usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.CategoriaAlias ); EntityBDto entityBDto = new EntityBDto(); entityBDto.Id = entityB.Id; entityBDto.Name = entityB.Name; // Devolvemos el resultado. return(entityBDto); } // EntityMapping
public EntityBDto EntityMapping(IEntityB entityB) { // Comprobamos el parámetro de entrada. Guard.ArgumentIsNotNull( entityB, string.Format( Inflexion2.Resources.Framework.MapperErrorEntityNull, "Entity B") // usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.CategoriaAlias ); EntityBDto entityBDto = new EntityBDto(); entityBDto.Id = entityB.Id; entityBDto.Name = entityB.Name; // Devolvemos el resultado. return entityBDto; } // EntityMapping
public int CreateEntity(IEntityB entityB) { try { if (entityB != null) { entityB.Id = new Random().Next();; RepositoryDbContext.EntitiesB.Add(entityB); return(entityB.Id); } } catch (Exception exception) { throw new DbUpdateException(GetType().FullName + " - " + MethodBase.GetCurrentMethod().Name, exception); } return(0); }
public bool DeleteEntity(IEntityB entityB) { try { EntityB original = (EntityB)RepositoryDbContext.EntitiesB.Find(entityB.Id); if (original != null) { RepositoryDbContext.EntitiesB.Remove(original); return(true); } } catch (Exception exception) { throw new DbUpdateException(GetType().FullName + " - " + MethodBase.GetCurrentMethod().Name, exception); } return(false); }
} // EntityMapping /// <summary> /// Metodo encargado de obtener una nueva entidad a partir de la información de un Dto /// L /// </summary> /// <param name="entityBDto"></param> /// <returns></returns> public IEntityB DataMapping(EntityBDto entityBDto) { // Comprobamos el parámetro de entrada. Guard.ArgumentIsNotNull( entityBDto, string.Format( Inflexion2.Resources.Framework.MapperErrorEntityNull, "Entity B DTo") // usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.CategoriaAlias ); Guard.ArgumentIsNotNull( entityBDto.Name, string.Format( Inflexion2.Resources.Framework.PropertyRequired, "Name", "Entity B DTo") // usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.CategoriaAlias ); IEntityB entityB = EntityBFactory.Create(entityBDto.Name); return(entityB); }
public bool UpdateEntity(IEntityB entityB) { EntityB original = (EntityB)RepositoryDbContext.EntitiesB.Find(entityB.Id); try { if (original != null) { original.Username = entityB.Username; original.Email = entityB.Email; return(true); } } catch (Exception exception) { throw new DbUpdateException(GetType().FullName + " - " + MethodBase.GetCurrentMethod().Name, exception); } return(false); }