public async Task <ActionResult <CatEstados> > PostCatEstados(CatEstados catEstados) { _context.CatEstados.Add(catEstados); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCatEstados", new { id = catEstados.Idestado }, catEstados)); }
public async Task <IActionResult> PutCatEstados(int id, CatEstados catEstados) { if (id != catEstados.Idestado) { return(BadRequest()); } _context.Entry(catEstados).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatEstadosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ApiResponse <DTODerechohabiente> > GetDerechohabienteService(string noIssste) { ApiResponse <DTODerechohabiente> apiResponse = new ApiResponse <DTODerechohabiente>(); try { string result = string.Empty; string aVBaseUrl = ConfigurationManager.AppSettings["InformixWSBaseUrl"]; string aVService = string.Format(ConfigurationManager.AppSettings["InformixWSEntitle"], noIssste); using (var client = new HttpClient()) { client.BaseAddress = new Uri(aVBaseUrl); HttpResponseMessage response = await client.GetAsync(aVService); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsStringAsync(); } } if (result.Length >= 3) { DTODerechohabienteService derechohabienteService = JsonConvert.DeserializeObject <IList <DTODerechohabienteService> >(result).FirstOrDefault(); GenericDataRepository <CatEstados> estadosRepository = new GenericDataRepository <CatEstados>(); CatEstados estadoDerechohabiente = estadosRepository.GetSingle(x => x.Clave == derechohabienteService.EntityBirth); apiResponse.Data = new DTODerechohabiente() { Nombre = derechohabienteService.Name, ApellidoPaterno = derechohabienteService.FirstSurname, ApellidoMaterno = derechohabienteService.SecondSurname, NombreCompleto = string.Join(" ", new[] { derechohabienteService.Name, derechohabienteService.FirstSurname, derechohabienteService.SecondSurname }), FechaNacimiento = derechohabienteService.BirthDate, Edad = DateTime.Now.Year - derechohabienteService.BirthDate.Year, Rfc = derechohabienteService.Rfc, Curp = derechohabienteService.Curp, NoIssste = derechohabienteService.NumIssste, Delegacion = derechohabienteService.DelegationCode, Afiliacion = derechohabienteService.State, IdGenero = derechohabienteService.Genger == "M" ? 1 : 2, Genero = derechohabienteService.Genger == "M" ? "MUJER" : "HOMBRE", IdEstado = estadoDerechohabiente.IdEstado, TipoDerechohabiente = derechohabienteService.DirectType == "T" ? "TRABAJADOR" : "PENSIONADO", Estado = estadoDerechohabiente.Nombre.ToUpper() }; if (apiResponse.Data != null) { apiResponse.Result = (int)ApiResult.Success; apiResponse.Message = Resources.ConsultaExitosa; } else { apiResponse.Result = (int)ApiResult.Failure; apiResponse.Message = Resources.ConsultaFallida; } } else { apiResponse.Result = (int)ApiResult.Failure; apiResponse.Message = Resources.ConsultaFallida; } } catch (Exception ex) { apiResponse.Result = (int)ApiResult.Exception; apiResponse.Message = ex.Message; } return(apiResponse); }