/// <summary>
        /// Converts this instance of <see cref="datahierarchy"/> to an instance of <see cref="datahierarchyDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="datahierarchy"/> to convert.</param>
        public static datahierarchyDto ToDTO(this datahierarchy entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new datahierarchyDto();

            dto.i_GroupId         = entity.i_GroupId;
            dto.i_ItemId          = entity.i_ItemId;
            dto.v_Value1          = entity.v_Value1;
            dto.v_Value2          = entity.v_Value2;
            dto.v_Field           = entity.v_Field;
            dto.i_ParentItemId    = entity.i_ParentItemId;
            dto.i_Sort            = entity.i_Sort;
            dto.i_IsDeleted       = entity.i_IsDeleted;
            dto.i_InsertUserId    = entity.i_InsertUserId;
            dto.d_InsertDate      = entity.d_InsertDate;
            dto.i_UpdateUserId    = entity.i_UpdateUserId;
            dto.d_UpdateDate      = entity.d_UpdateDate;
            dto.v_ComentaryUpdate = entity.v_ComentaryUpdate;

            entity.OnDTO(dto);

            return(dto);
        }
        /// <summary>
        /// Converts this instance of <see cref="datahierarchyDto"/> to an instance of <see cref="datahierarchy"/>.
        /// </summary>
        /// <param name="dto"><see cref="datahierarchyDto"/> to convert.</param>
        public static datahierarchy ToEntity(this datahierarchyDto dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new datahierarchy();

            entity.i_GroupId         = dto.i_GroupId;
            entity.i_ItemId          = dto.i_ItemId;
            entity.v_Value1          = dto.v_Value1;
            entity.v_Value2          = dto.v_Value2;
            entity.v_Field           = dto.v_Field;
            entity.i_ParentItemId    = dto.i_ParentItemId;
            entity.i_Sort            = dto.i_Sort;
            entity.i_IsDeleted       = dto.i_IsDeleted;
            entity.i_InsertUserId    = dto.i_InsertUserId;
            entity.d_InsertDate      = dto.d_InsertDate;
            entity.i_UpdateUserId    = dto.i_UpdateUserId;
            entity.d_UpdateDate      = dto.d_UpdateDate;
            entity.v_ComentaryUpdate = dto.v_ComentaryUpdate;

            dto.OnEntity(entity);

            return(entity);
        }
Пример #3
0
        public void AddDataHierarchy(ref OperationResult pobjOperationResult, datahierarchyDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                datahierarchy         objEntity = datahierarchyAssembler.ToEntity(pobjDtoEntity);


                objEntity.d_InsertDate   = DateTime.Now;
                objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                objEntity.i_IsDeleted    = 0;

                dbContext.AddTodatahierarchy(objEntity);
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "DATA HIERARCHY", "GroupId=" + objEntity.i_GroupId.ToString() + " / Descripción = " + objEntity.v_Value1, Success.Ok, null);

                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = ex.Message;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "DATA HIERARCHY", "GroupId=" + pobjDtoEntity.i_GroupId.ToString() + " / Descripción = " + pobjDtoEntity.v_Value1, Success.Failed, ex.Message);
                return;
            }
        }
Пример #4
0
        public void UpdateDataHierarchy(ref OperationResult pobjOperationResult, datahierarchyDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();

                // Obtener la entidad fuente
                var objEntitySource = (from a in dbContext.datahierarchy
                                       where a.i_GroupId == pobjDtoEntity.i_GroupId && a.i_ItemId == pobjDtoEntity.i_ItemId
                                       select a).FirstOrDefault();

                // Crear la entidad con los datos actualizados
                pobjDtoEntity.d_UpdateDate   = DateTime.Now;
                pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                datahierarchy objEntity = datahierarchyAssembler.ToEntity(pobjDtoEntity);

                // Copiar los valores desde la entidad actualizada a la Entidad Fuente
                dbContext.datahierarchy.ApplyCurrentValues(objEntity);

                // Guardar los cambios
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;

                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "DATA HIERARCHY", "GroupId=" + objEntity.i_GroupId.ToString() + " / Descripción = " + objEntity.v_Value1, Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = ex.Message;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "DATA HIERARCHY", "GroupId=" + pobjDtoEntity.i_GroupId.ToString() + " / Descripción = " + pobjDtoEntity.v_Value1, Success.Failed, ex.Message);
                return;
            }
        }
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="datahierarchy"/> converted from <see cref="datahierarchyDto"/>.</param>
 static partial void OnEntity(this datahierarchyDto dto, datahierarchy entity);
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="datahierarchyDto"/> converted from <see cref="datahierarchy"/>.</param>
 static partial void OnDTO(this datahierarchy entity, datahierarchyDto dto);