Beispiel #1
0
        public async Task <IActionResult> OnGet()
        {
            _ = await _eventData.DeleteEventAsync(Id);

            TempData["Success"] = "Event was deleted successfully";
            return(RedirectToPage("/Admin/Events"));
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteEvent([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var eventToDelete = await _eventService.GetEventByIDAsync(id);

            if (eventToDelete == null)
            {
                return(NotFound());
            }

            await _eventService.DeleteEventAsync(id);

            return(Ok(eventToDelete));
        }