public async Task <ResultModel <string> > ReportStoryAsync(CreateStoryReportRequestModel model, string reporterId) { var isBanned = await this.usersService.IsBanned(reporterId); if (isBanned) { return(new ResultModel <string> { Errors = { StoryReportErrors.BannedUserReports } }); } var storyReport = new StoryReport { Title = model.Title, Content = model.Content, IsRead = false, ReporterId = reporterId, StoryId = model.StoryId, }; await this.dbContext.StoryReports.AddAsync(storyReport); await this.dbContext.SaveChangesAsync(); return(new ResultModel <string> { Result = storyReport.Id, Success = true, }); }
public async Task <ActionResult> Create(CreateStoryReportRequestModel model) { var loggedUser = this.User.GetId(); var result = await this.storyReportsService.ReportStoryAsync(model, loggedUser); if (!result.Success) { return(BadRequest(result.Errors)); } return(Created(nameof(Create), result.Result)); }