public ConveniosPCTRs ConveniosPCT(string identificacion, ConveniosPCTRq body) { var convenio = convenioContext.Convenio.Find(identificacion); if (convenio != null) { convenioContext.Convenio.Update(body.Convenio); //convenioContext.Entry(body.Convenio).State = EntityState.Modified; convenioContext.SaveChanges(); ConveniosPCTRs rs = new ConveniosPCTRs { Convenio = new Convenio() }; if (body.Convenio.TipoConvenio != null) { rs.Convenio.TipoConvenio = body.Convenio.TipoConvenio; } if (body.Convenio.Ciudad != null) { rs.Convenio.Ciudad = body.Convenio.Ciudad; } if (body.Convenio.Correo != null) { rs.Convenio.Correo = body.Convenio.Correo; } if (body.Convenio.TipoConvenio != null) { rs.Convenio.FechaVigencia = body.Convenio.FechaVigencia; } if (body.Convenio.Identificacion != null) { rs.Convenio.Identificacion = body.Convenio.Identificacion; } if (body.Convenio.NombreProveedor != null) { rs.Convenio.NombreProveedor = body.Convenio.NombreProveedor; } //convenios[convenios.FindIndex(c => c.Identificacion == body.Convenio.Identificacion)] = rs.Convenio; return(rs); } else { throw new ConvenioNoExisteException("No existe el convenio"); } }
//[SwaggerResponse(statusCode: 201, type: typeof(ConveniosPCTRs), description: "Convenio actualizado exitosamente")] public virtual IActionResult ConveniosPCT([FromRoute][Required] string identificacion, [FromBody] ConveniosPCTRq body) { try { if (ModelState.IsValid) { var conv = _repository.Convenio.GetConvenioById(body.Convenio.Identificacion); if (conv == null) { return(NotFound()); } else { var convenios = _repository.Convenio.UpdateConvenio(body.Convenio as Convenio); if (convenios == null) { return(NoContent()); } else { return(StatusCode(201, convenios)); } } } else { return(BadRequest()); } } catch (ConvenioNoExisteException e) { return(NotFound(e.Message)); } catch (ConvenioYaExisteException e) { return(Conflict(e.Message)); } }