public string AddMasterRecommendationRestricction(ref OperationResult pobjOperationResult, masterrecommendationrestricctionDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;
            string NewId = "(No generado)";

            try
            {
                SigesoftEntitiesModel            dbContext = new SigesoftEntitiesModel();
                masterrecommendationrestricction objEntity = masterrecommendationrestricctionAssembler.ToEntity(pobjDtoEntity);

                objEntity.d_InsertDate   = DateTime.Now;
                objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                objEntity.i_IsDeleted    = 0;
                // Autogeneramos el Pk de la tabla
                int intNodeId = int.Parse(ClientSession[0]);
                NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 43), "MR");;
                objEntity.v_MasterRecommendationRestricctionId = NewId;

                dbContext.AddTomasterrecommendationrestricction(objEntity);
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "RECOMENDACIÓN / RESTRICCIÓN", "v_MasterRecommendationRestricctionId=" + NewId.ToString(), Success.Ok, null);
                return(NewId);
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "RECOMENDACIÓN / RESTRICCIÓN", "v_MasterRecommendationRestricctionId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return(null);
            }
        }
Example #2
0
        public void UpdateMasterRecommendationRestricction(ref OperationResult pobjOperationResult, masterrecommendationrestricctionDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;
            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();

                // Obtener la entidad fuente
                var objEntitySource = (from a in dbContext.masterrecommendationrestricction
                                       where a.v_MasterRecommendationRestricctionId == pobjDtoEntity.v_MasterRecommendationRestricctionId
                                       select a).FirstOrDefault();



                // Crear la entidad con los datos actualizados
                pobjDtoEntity.v_Name         = pobjDtoEntity.v_Name;
                pobjDtoEntity.i_TypifyingId  = objEntitySource.i_TypifyingId;
                pobjDtoEntity.i_IsDeleted    = 1;
                pobjDtoEntity.i_InsertUserId = objEntitySource.i_InsertUserId;
                pobjDtoEntity.d_InsertDate   = objEntitySource.d_InsertDate;
                pobjDtoEntity.d_UpdateDate   = DateTime.Now;
                pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]);

                masterrecommendationrestricction objEntity = masterrecommendationrestricctionAssembler.ToEntity(pobjDtoEntity);

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

                // Guardar los cambios
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "RECOMENDACIÓN / RESTRICCIÓN", "v_MasterRecommendationRestricctionId=" + objEntity.v_MasterRecommendationRestricctionId.ToString(), Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "RECOMENDACIÓN / RESTRICCIÓN", "v_MasterRecommendationRestricctionId=" + pobjDtoEntity.v_MasterRecommendationRestricctionId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return;
            }
        }
        /// <summary>
        /// Converts this instance of <see cref="masterrecommendationrestricction"/> to an instance of <see cref="masterrecommendationrestricctionDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="masterrecommendationrestricction"/> to convert.</param>
        public static masterrecommendationrestricctionDto ToDTO(this masterrecommendationrestricction entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new masterrecommendationrestricctionDto();

            dto.v_MasterRecommendationRestricctionId = entity.v_MasterRecommendationRestricctionId;
            dto.v_Name         = entity.v_Name;
            dto.i_TypifyingId  = entity.i_TypifyingId;
            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;

            entity.OnDTO(dto);

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

            var entity = new masterrecommendationrestricction();

            entity.v_MasterRecommendationRestricctionId = dto.v_MasterRecommendationRestricctionId;
            entity.v_Name         = dto.v_Name;
            entity.i_TypifyingId  = dto.i_TypifyingId;
            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;

            dto.OnEntity(entity);

            return(entity);
        }
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="masterrecommendationrestricction"/> converted from <see cref="masterrecommendationrestricctionDto"/>.</param>
 static partial void OnEntity(this masterrecommendationrestricctionDto dto, masterrecommendationrestricction entity);
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="masterrecommendationrestricctionDto"/> converted from <see cref="masterrecommendationrestricction"/>.</param>
 static partial void OnDTO(this masterrecommendationrestricction entity, masterrecommendationrestricctionDto dto);