public ProcessResult <VariableValorResponse> RegistrarVariableValor(VariableValorRequest data) { ProcessResult <VariableValorResponse> resultado = new ProcessResult <VariableValorResponse>(); resultado.Result = new VariableValorResponse(); try { using (TransactionScope ts = new TransactionScope()) { VariableValorEntity VariableValorSincronizar = variableValorEntityRepository.GetById(data.CodigoVariableValor); VariableValorEntity VariableValorGeneral = Mapper.Map <VariableValorRequest, VariableValorEntity>(data); if (VariableValorSincronizar != null) { Mapper.Map <VariableValorEntity, VariableValorEntity>(VariableValorGeneral, VariableValorSincronizar); variableValorEntityRepository.Editar(VariableValorSincronizar); resultado.Result.CodigoVariableValor = data.CodigoVariableValor; resultado.Result.CodigoVariable = data.CodigoVariable; } else { variableValorEntityRepository.Insertar(VariableValorGeneral); bool registroExitoso = resultado.IsSuccess; if (!registroExitoso) { resultado.IsSuccess = false; resultado.Exception = new ApplicationLayerException <VariableValorService>(MensajesSistemaResource.EtiquetaError); } resultado.Result.CodigoVariableValor = VariableValorGeneral.CodigoVariableValor; resultado.Result.CodigoVariable = VariableValorGeneral.CodigoVariable; } variableValorEntityRepository.GuardarCambios(); ts.Complete(); } } catch (Exception ex) { resultado.IsSuccess = false; resultado.Exception = new ApplicationLayerException <VariableValorService>(ex.Message); } return(resultado); }
public ProcessResult <object> EliminarVariableValor(VariableValorRequest data) { ProcessResult <object> resultado = new ProcessResult <object>(); resultado.Result = string.Empty; try { VariableValorEntity oVariableValorEntity = variableValorEntityRepository.GetById(data.CodigoVariableValor); if (oVariableValorEntity != null) { variableValorEntityRepository.Eliminar(oVariableValorEntity.CodigoVariableValor); resultado.IsSuccess = true; variableValorEntityRepository.GuardarCambios(); } } catch (Exception ex) { resultado.Exception = new ApplicationLayerException <AreaService>(ex.Message); } return(resultado); }