public async Task <Response <int> > Insert(MunicipalidadDto.RQInsert input) { try { var responseInsert = new Response <int>(); var modelReq = this._mapper.Map <TM_MUNICIPALIDAD>(input); var result = await this._municipalidadDomain.Insert(modelReq); var nestadoProceso = Int32.Parse(result.STR_ESTADOPROCESO); if (nestadoProceso == 1) { responseInsert.IsSuccess = true; responseInsert.Data = result.NUM_IDENTIDAD.Value; responseInsert.Message = result.STR_MENSAJE; } else if (nestadoProceso > 1) { responseInsert.Message = result.STR_MENSAJE; } else if (nestadoProceso == 0) { throw new Exception(result.STR_MENSAJE); } return(responseInsert); } catch (Exception ex) { throw ex; } }
public async Task <Response <int> > Insert([FromBody] MunicipalidadDto.RQInsert input) { try { input.nIdSession = 0; input.sUsuario = ""; var oUserInfo = await this._jwtApplication.GetUserInfo(User); if (oUserInfo.IsSuccess) { input.nIdSession = Int32.Parse(oUserInfo.Data.sIdSession); input.sUsuario = oUserInfo.Data.sUsername; } var responseInsert = new Response <int>(); // INSERTAR MUNICIPALIDAD EN EL SSO 58930 60288 var rEnterpriseNew = await this._sSOApplication.EnterpriseNew(input.sRuc); if (!rEnterpriseNew.IsSuccess) { responseInsert.Message = rEnterpriseNew.Message; return(responseInsert); } if (rEnterpriseNew.Data.IdPersona == 0) { responseInsert.Message = "Ya se encuentra registrado."; return(responseInsert); } // ASIGNAR APLICATIVO A MUNICIPALIDAD EN EL SSO 75066 var rEnterpriseAttachApp = await this._sSOApplication.EnterpriseAttachApp( rEnterpriseNew.Data.IdPersona.ToString(), input.sRuc); if (!rEnterpriseAttachApp.IsSuccess) { responseInsert.Message = rEnterpriseAttachApp.Message; return(responseInsert); } // CREAR LOCAL DE MUNICIPALIDAD EN EL SSO 6213 var rEnterpriseAddLocal = await this._sSOApplication.EnterpriseAddLocal( rEnterpriseNew.Data.IdPersona.ToString(), input.sRuc, rEnterpriseAttachApp.Data.Value, "LOCAL PRINCIPAL", "-" ); if (!rEnterpriseAddLocal.IsSuccess) { responseInsert.Message = rEnterpriseAddLocal.Message; return(responseInsert); } input.nIdentidadsso = rEnterpriseNew.Data.IdPersona; input.nIdLocalsso = Int32.Parse(rEnterpriseAddLocal.Data.Value); return(await _municipalidadApplication.Insert(input)); } catch (Exception ex) { _ = this._logApplication.SetLog(EnumLogType.TEXT_N_EMAIL, EnumLogCategory.ERROR, "Municipalidad-Insert", ex, input); return(new Response <int> { Message = "ERR-Fallo en el servidor" }); } }