public async Task <IActionResult> PutInvestigador(string id, Investigador investigador) { if (id != investigador.Dni) { return(BadRequest()); } _context.Entry(investigador).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvestigadorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public CursoInvestigador[] FindUnsedCursosInvestigador(Investigador investigador) { var cursos = DetachedCriteria.For(typeof (Curso)) .CreateAlias("CursoInvestigador", "ci") .SetProjection(Projections.ProjectionList() .Add(Projections.Property("ci.Id"), "CursoInvestigadorId")); var cursoInvestigador = Session.CreateCriteria(typeof (CursoInvestigador)) .Add(Expression.Eq("Investigador", investigador)) .Add(Subqueries.PropertyNotIn("Id", cursos)) .List<CursoInvestigador>(); return ((List<CursoInvestigador>) cursoInvestigador).ToArray(); }
public async Task <ActionResult <Investigador> > PostInvestigador(Investigador investigador) { _context.Investigadores.Add(investigador); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (InvestigadorExists(investigador.Dni)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetInvestigador", new { id = investigador.Dni }, investigador)); }