NET 6 - API

Last modified: March 26, 2022
  • Select TicketingSystem.RazorPages project
  • Create a new controller EventController on Controller folder

api

api

[Route("api/[controller]")] [ApiController] public class EventController : ControllerBase { private readonly EventService _eventService; public EventController(EventService eventService) { _eventService = eventService; } public async Task<List<EventViewModel>> GetAll() { return await _eventService.GetAllAsync(); } public async Task<EventViewModel> GetById(string Id) { return await _eventService.GetById(Id); } public async Task Create(EventViewModel eventViewModel) { await _eventService.Add(eventViewModel); } public async Task Update(EventViewModel eventViewModel) { await _eventService.Update(eventViewModel); } public async Task Delete(string id) { await _eventService.Delete(id); } }

You can do same things for EventBooking