public async Task <IActionResult> CreateAsync([FromBody] InReportDTO reportDTO) { var report = ReportMapper.Map(reportDTO); report = _repositoryManager.ReportRepository.Create(report); await _repositoryManager.SaveAsync(); return(Ok(ReportMapper.Map(report))); }
public async Task <IActionResult> PostReport(int id, [FromBody] ReportViewModel model) { var @event = await DbContext.Events.SingleOrDefaultAsync(e => e.Id == id); if (@event == null) { return(NotFound()); } var report = ReportMapper.Update(new Report(), model); @event.EventReports.Add(new EventReport { Report = report }); await DbContext.SaveChangesAsync(); return(CreatedAtRoute("GetReport", new { id = report.Id }, ReportMapper.Map(report))); }
private IActionResult ListReportsPublished(Event @event) { var reports = @event.EventReports.Where(er => er.Report.State == Models.EntityState.Published).Select(r => ReportMapper.Map(r.Report)).ToList(); return(Ok(reports)); }
private IActionResult ListReportsUndeletedAsync(Event @event) { var reports = @event.EventReports.Where(er => er.Report.State != Models.EntityState.Deleted).Select(r => ReportMapper.Map(r.Report)).ToList(); return(Ok(reports)); }