Spaces:
Runtime error
Runtime error
almakhmri253-stack
security hardening: rate limiting, account lockout, security headers, password strength
8a2f194 Download Controllers/EventsController.cs from azizproject/majlis: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/azizproject/majlis/resolve/main/Controllers/EventsController.cs
- Command line
-
hf download hf://spaces/azizproject/majlis/Controllers/EventsController.cs
-
curl -L -o EventsController.cs https://huggingface.co/spaces/azizproject/majlis/resolve/main/Controllers/EventsController.cs
1.64 kB
| using System.Security.Claims; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using MajlisManagement.DTOs; | |
| using MajlisManagement.Services.Interfaces; | |
| namespace MajlisManagement.Controllers; | |
| [] | |
| [] | |
| public class EventsController : ControllerBase | |
| { | |
| private readonly IEventService _events; | |
| public EventsController(IEventService events) => _events = events; | |
| [] | |
| [] | |
| public async Task<IActionResult> GetAll() | |
| { | |
| var list = await _events.GetAllAsync(); | |
| return Ok(list); | |
| } | |
| [] | |
| [] | |
| public async Task<IActionResult> Create([FromBody] CreateEventDto dto) | |
| { | |
| if (string.IsNullOrWhiteSpace(dto.Title)) | |
| return BadRequest(new { message = "العنوان مطلوب" }); | |
| var userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); | |
| var result = await _events.CreateAsync(userId, dto); | |
| return CreatedAtAction(nameof(GetAll), new { id = result.Id }, result); | |
| } | |
| [] | |
| [] | |
| public async Task<IActionResult> Update(int id, [FromBody] UpdateEventDto dto) | |
| { | |
| if (string.IsNullOrWhiteSpace(dto.Title)) | |
| return BadRequest(new { message = "العنوان مطلوب" }); | |
| var result = await _events.UpdateAsync(id, dto); | |
| return Ok(result); | |
| } | |
| [] | |
| [] | |
| public async Task<IActionResult> Delete(int id) | |
| { | |
| await _events.DeleteAsync(id); | |
| return NoContent(); | |
| } | |
| } | |