Spaces:
Runtime error
Runtime error
almakhmri253-stack
security hardening: rate limiting, account lockout, security headers, password strength
8a2f194 Download Controllers/ComplaintsController.cs from azizproject/majlis: direct link, hf CLI and curl.
- Browser
- Download file 2.77 kB
-
https://huggingface.co/spaces/azizproject/majlis/resolve/main/Controllers/ComplaintsController.cs
- Command line
-
hf download hf://spaces/azizproject/majlis/Controllers/ComplaintsController.cs
-
curl -L -o ComplaintsController.cs https://huggingface.co/spaces/azizproject/majlis/resolve/main/Controllers/ComplaintsController.cs
2.77 kB
| using System.Security.Claims; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using MajlisManagement.DTOs; | |
| using MajlisManagement.Middleware; | |
| using MajlisManagement.Services.Interfaces; | |
| namespace MajlisManagement.Controllers; | |
| [] | |
| [] | |
| public class ComplaintsController : ControllerBase | |
| { | |
| private readonly IComplaintService _complaints; | |
| public ComplaintsController(IComplaintService complaints) => _complaints = complaints; | |
| /// <summary>إرسال ملاحظة أو شكوى (مسموح للجميع، حتى بدون تسجيل)</summary> | |
| [] | |
| [] | |
| public async Task<IActionResult> Create([FromBody] CreateComplaintDto dto) | |
| { | |
| int? userId = null; | |
| if (User.Identity?.IsAuthenticated == true) | |
| userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); | |
| var result = await _complaints.CreateAsync(userId, dto); | |
| return Ok(new { message = "تم إرسال ملاحظتك بنجاح", id = result.Id }); | |
| } | |
| /// <summary>الشكاوى والمقترحات المنشورة للعموم (بدون تسجيل دخول)</summary> | |
| [] | |
| [] | |
| public async Task<IActionResult> GetPublic() | |
| { | |
| var result = await _complaints.GetPublicAsync(); | |
| return Ok(result); | |
| } | |
| /// <summary>نشر أو إلغاء نشر شكوى (Admin فقط)</summary> | |
| [] | |
| [] | |
| public async Task<IActionResult> TogglePublish(int id) | |
| { | |
| var result = await _complaints.TogglePublicAsync(id); | |
| var msg = result.IsPublic ? "تم نشر الرسالة للعموم" : "تم إلغاء النشر"; | |
| return Ok(new { message = msg, isPublic = result.IsPublic }); | |
| } | |
| /// <summary>عرض جميع الملاحظات</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> GetAll() | |
| { | |
| var result = await _complaints.GetAllAsync(); | |
| return Ok(result); | |
| } | |
| /// <summary>جلب ملاحظة بالمعرف</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> GetById(int id) | |
| { | |
| var result = await _complaints.GetByIdAsync(id); | |
| return Ok(result); | |
| } | |
| /// <summary>الرد على ملاحظة</summary> | |
| [] | |
| [] | |
| [] | |
| public async Task<IActionResult> Respond(int id, [FromBody] RespondComplaintDto dto) | |
| { | |
| var result = await _complaints.RespondAsync(id, dto); | |
| return Ok(result); | |
| } | |
| } | |