public async Task <Reports> CreateAsync(Reports model) { return(await TryCatch(async() => { var reports = await _reportsRepository.CreateAsync(model); return reports; })); }
public async Task <IActionResult> Create( [FromRoute] int announcementId, [FromBody] CreateReportDto reportDto) { var report = new Report { ReportCause = reportDto.ReportCause, ReportDescription = reportDto.ReportDescription, ReportDate = DateTime.UtcNow, AnnouncementId = announcementId }; await _reportsRepository.CreateAsync(report); var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var locationUri = baseUrl + ApiRoutes.Reports.Get.Replace("{reportId}", report.Id.ToString()); var response = new ReportResponse { Id = report.Id }; return(Created(locationUri, response)); }