Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/report #27

Merged
merged 6 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public interface IReportServices:IScopedDependency
Task<List<ReportDto>> GetAllReport();
Task<bool> PostReport(PostReportDto reportDto);
Task<bool> DeleteReport(int reportId);
Task<Report> UpdateReportStatusAsync(int id, Status status);



}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public record PostReportDto
[Required]
public int UserId { get; set; }
[Required]
public int CommentId { get; set; }
public int CommentId{ get; set; }
}
}
3 changes: 2 additions & 1 deletion src/VakilPors/VakilPors.Core/Domain/Dtos/Report/ReportDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using VakilPors.Core.Domain.Dtos.User;
using VakilPors.Core.Domain.Entities;

namespace VakilPors.Core.Domain.Dtos.Report
{
Expand All @@ -13,7 +14,7 @@ public record ReportDto
public string Description { get; set; }
public UserDto User { get; set; }
public ThreadCommentDto ThreadComment { get; set; }

public Status status{get;set;}

}
}
9 changes: 9 additions & 0 deletions src/VakilPors/VakilPors.Core/Domain/Entities/Category.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace VakilPors.Core.Domain.Entities;

public enum Category
{
BAD_LANGUAGE,
ILLEGAL,
OTHER

}
6 changes: 3 additions & 3 deletions src/VakilPors/VakilPors.Core/Domain/Entities/Report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class Report :IEntity
public int UserId { get; set; }
[ForeignKey(nameof(UserId))]
public virtual User User { get; set; }
public int CommentId { get; set; }
public int CommentId{ get; set; }
[ForeignKey(nameof(CommentId))]
public virtual ThreadComment ThreadComment { get; set; }
//TODO: create enum(install extension)
public virtual ThreadComment ThreadComment { get; set; }
public Status Status { get; set; } = Status.PENDING;
}
15 changes: 15 additions & 0 deletions src/VakilPors/VakilPors.Core/Services/ReportServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using AutoMapper;
using MimeKit.Encodings;
using Microsoft.AspNetCore.Mvc;
using VakilPors.Core.Exceptions;

namespace VakilPors.Core.Services
{
Expand Down Expand Up @@ -80,6 +81,20 @@ public async Task<bool> DeleteReport(int reportId)
return false; // Report deletion failed
}
}
public async Task<Report> UpdateReportStatusAsync(int id, Status status)
{
var existingReport = await _appUnitOfWork.ReportRepo.AsQueryable()
.FirstOrDefaultAsync(e=>e.Id==id);
if (existingReport == null)
{
throw new NotFoundException("Report not found.");
}

existingReport.Status = status;
await _appUnitOfWork.SaveChangesAsync();

return existingReport;
}

}

Expand Down
Loading
Loading