public async Task <IActionResult> DeleteAsync(string id) { if (HttpContext.Session.GetObjectFromJson <User>("loggedUser") == null) { return(Unauthorized()); } if (!HttpContext.Session.GetObjectFromJson <User>("loggedUser").IsAdmin) { return(Unauthorized()); } Actor actor; try { actor = actorRepo.Get(a => a.Id == id); if (actor == null) { return(NotFound()); } actorRepo.Delete(actor); } catch (Exception ex) { await _logger.LogCustomExceptionAsync(ex, null); return(BadRequest()); } return(Ok(actor)); }
public IActionResult Delete(string id) { if (HttpContext.Session.GetObjectFromJson <User>("loggedUser") == null) { return(Unauthorized()); } if (!HttpContext.Session.GetObjectFromJson <User>("loggedUser").IsAdmin) { return(Unauthorized()); } Actor actor = actorRepo.Get(a => a.Id == id); if (actor == null) { return(NotFound()); } actorRepo.Delete(actor); return(Ok(actor)); }