public async Task <IActionResult> Index() { var addresses = _dbContext.Addresses .Include(address => address.Students); var students = _dbContext.Students .Include(student => student.Address) .Include(student => student.Exams) .ThenInclude(exam => exam.Exam); var exams = _dbContext.Exams; var transcripts = _dbContext.Transcripts; var t = _service.GetTranscript(2, 1); var a = _service.GetTranscripts(); var tDTO = new TranscriptDTO { ExamId = 1, StudentId = 5, Points = 30 }; t = _service.SaveTranscript(tDTO); tDTO.Points = 60; t = _service.PutPoints(t.Id, tDTO); _service.DeleteTranscript(t.Id); return(View()); }
public TranscriptDTO SaveTranscript(TranscriptDTO transcript) { Transcript newTranscript = _mapper.Map <Transcript>(transcript); _dataContext.Transcripts.Add(newTranscript); _dataContext.SaveChanges(); return(_mapper.Map <TranscriptDTO>(newTranscript)); }
public IActionResult Post([FromBody] TranscriptDTO transcript) { if (ModelState.IsValid) { var result = _service.SaveTranscript(transcript); return(Ok(result)); } return(BadRequest(ModelState)); }
public TranscriptDTO PutPoints(int id, TranscriptDTO transcriptObject) { var transcript = _dataContext.Transcripts.FirstOrDefault(x => x.Id == id); if (transcript == null) { throw new Exception("Transcript not found"); } transcriptObject.Id = transcript.Id; transcript = _mapper.Map <Transcript>(transcriptObject); _dataContext.SaveChanges(); return(_mapper.Map <TranscriptDTO>(transcript)); }
public TranscriptDTO PutPoints([FromRoute] int id, [FromBody] TranscriptDTO transcriptObject) { return(_service.PutPoints(id, transcriptObject)); }