//Int32 Create(EntityADto entityADto, UserContextDto userContextDto);// invocacion con identificación de usuario public int Create(EntityBDto entityBDto) { #region Preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( entityBDto, string.Format( Inflexion2.Resources.Framework.DataTransferObjectIsNull, "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBAlias // Comprobar los campos mandatory dentro del DTO. Guard.ArgumentNotNullOrEmpty( entityBDto.Name, string.Format( Inflexion2.Resources.Framework.PropertyRequired, "Name", "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBNameAlias // el dto debe corresponder a un transient el id debe tener el valor por defecto //if (entityBDto.Id != default(int)) Guard.Against <ArgumentException>(entityBDto.Id != default(int), string.Format( Inflexion2.Resources.Framework.IsNotTransient, "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBNameAlias #endregion EntityB entityB = EntityBFactory.Create(entityBDto.Name); IEntityBRepository repo = this.unityContainer.Resolve <IEntityBRepository>(); repo.Add(entityB); this.Commit(); return(entityB.Id); }
//EntityADto GetById(Int32 entityAId, UserContextDto userContextDto); public EntityBDto GetById(Int32 entityBId) { // Variable de respuesta. EntityBDto entityDto = null; try { IEntityBRepository repo = this.unityContainer.Resolve <IEntityBRepository>(); // Obtener y comprobar la entidad. //ISpecification<EntityB> spec = new DirectSpecification<EntityB>(t => t.Id == entityBId); EntityB entity = repo.GetFilteredElements(t => t.Id == entityBId).Single(); string s = string.Format(Inflexion2.Resources.Framework.NoDataById, "Entity B", entityBId); if (s == null) { s = ""; } Guard.ArgumentIsNotNull(entity, s); // Mapeamos los datos. entityDto = this.EntityBMapper.EntityMapping(entity); // Confirmamos la transacción. this.Commit(); } catch (Exception ex) { // Escribimos en el Log. logger.Error(ex.Message, ex); throw ex; } // Devolvemos el resultado. return(entityDto); }
//bool Update(EntityADto entity1Dto, UserContextDto userContextDto); public bool Update(EntityBDto entityBDto) { #region preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( entityBDto, string.Format( Inflexion2.Resources.Framework.DataTransferObjectIsNull, "Entity B")); // comprobamos los campos mandatory ¿EN UNA ACTUALIZACIÓN TAMBIEN? Guard.ArgumentNotNullOrEmpty( entityBDto.Name, string.Format( Inflexion2.Resources.Framework.PropertyRequired, "Entity B")); #endregion try { IEntityBRepository repo = this.unityContainer.Resolve <IEntityBRepository>(); // Obtener y comprobar la entidad. //ISpecification<EntityB> spec = new DirectSpecification<EntityB>(t => t.Id == entityBDto.Id); EntityB entity2Update = repo.GetFilteredElements(t => t.Id == entityBDto.Id).Single(); Guard.ArgumentIsNotNull( entity2Update, string.Format( Inflexion2.Resources.Framework.CanNotUpdateInexistenceEntity, "Entity B")); // Mapeamos los datos, teniendo encuenta que el id lo hemos recuperado y comprobado // ademas comprobamos que valores han sido modificados if (entity2Update.Name != entityBDto.Name) { entity2Update.Name = entityBDto.Name; // opcion a trazar las modificaciones } // igualmente hemos de mapear las entidades emparentadas. if (!entity2Update.CanBeSaved()) { return(false); } repo.Modify(entity2Update); // Confirmamos la transacción. this.Commit(); } catch (Exception ex) { // Escribimos en el Log. //logger.Error(ex.Message, ex); throw ex; } // Devolvemos el resultado. return(true); }
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
} // EntityMapping 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; }
} // 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); }
//Int32 Create(EntityADto entityADto, UserContextDto userContextDto);// invocacion con identificación de usuario public int Create(EntityBDto entityBDto) { #region Preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( entityBDto, string.Format( Inflexion2.Resources.Framework.DataTransferObjectIsNull, "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBAlias // Comprobar los campos mandatory dentro del DTO. Guard.ArgumentNotNullOrEmpty( entityBDto.Name, string.Format( Inflexion2.Resources.Framework.PropertyRequired, "Name", "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBNameAlias // el dto debe corresponder a un transient el id debe tener el valor por defecto //if (entityBDto.Id != default(int)) Guard.Against<ArgumentException>(entityBDto.Id != default(int), string.Format( Inflexion2.Resources.Framework.IsNotTransient, "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBNameAlias #endregion EntityB entityB = EntityBFactory.Create(entityBDto.Name); IEntityBRepository repo = this.unityContainer.Resolve<IEntityBRepository>(); repo.Add(entityB); this.Commit(); return entityB.Id; }
//bool Update(EntityADto entity1Dto, UserContextDto userContextDto); public bool Update(EntityBDto entityBDto) { #region preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( entityBDto, string.Format( Inflexion2.Resources.Framework.DataTransferObjectIsNull, "Entity B")); // comprobamos los campos mandatory ¿EN UNA ACTUALIZACIÓN TAMBIEN? Guard.ArgumentNotNullOrEmpty( entityBDto.Name, string.Format( Inflexion2.Resources.Framework.PropertyRequired, "Entity B")); #endregion try { IEntityBRepository repo = this.unityContainer.Resolve<IEntityBRepository>(); // Obtener y comprobar la entidad. //ISpecification<EntityB> spec = new DirectSpecification<EntityB>(t => t.Id == entityBDto.Id); EntityB entity2Update = repo.GetFilteredElements(t => t.Id == entityBDto.Id).Single(); Guard.ArgumentIsNotNull( entity2Update, string.Format( Inflexion2.Resources.Framework.CanNotUpdateInexistenceEntity, "Entity B")); // Mapeamos los datos, teniendo encuenta que el id lo hemos recuperado y comprobado // ademas comprobamos que valores han sido modificados if (entity2Update.Name != entityBDto.Name) { entity2Update.Name = entityBDto.Name; // opcion a trazar las modificaciones } // igualmente hemos de mapear las entidades emparentadas. if (!entity2Update.CanBeSaved()) { return false; } repo.Modify(entity2Update); // Confirmamos la transacción. this.Commit(); } catch (Exception ex) { // Escribimos en el Log. //logger.Error(ex.Message, ex); throw ex; } // Devolvemos el resultado. return true; }
public bool Update(EntityBDto entityBDto) { return this.service.Update(entityBDto); } // end Update
public int Create(EntityBDto entityBDto) { return this.service.Create(entityBDto); }