public async Task <ExameResultView> SetaExameVisto(SetaExameVistoDto dto) { var resultExistente = await _repResultado.GetResultadoIniciado(dto.AlunoId, dto.hashSimulacao); if (resultExistente == null) { throw new Exception("Consulta não encontrada com código: " + dto.hashSimulacao); } var exame = resultExistente.ExameResultados.Where(p => p.Id == dto.ExameId).FirstOrDefault(); if (exame == null) { throw new Exception("Exame não encontrado com código: " + dto.ExameId); } exame.Selecionada = true; _repResultado.Update(resultExistente); await _repResultado.SaveChangesAsync(); var ret = new ExameResultView { Id = exame.Id, ImgExame = exame.ImgExame, Nome = exame.Nome, Selecionada = exame.Selecionada }; return(ret); }
public async Task <IActionResult> SetaExameVisto(SetaExameVistoDto dto) { try { var ret = _aplicResultado.SetaExameVisto(dto); return(Ok(ret.Result)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou: " + ex.Message)); } }