public DeleteNewsResult Delete(int id) { try { if (id <= 0) { throw new ArgumentNullException(nameof(id)); } NewsDTO savedNews = NewsManager.GetByID(id); if (savedNews == null) { throw new Exception("News not found"); } if (savedNews.CreateUser != Guid.Parse(User.FindFirst(c => c.Type == ClaimTypes.NameIdentifier).Value)) { throw new UnauthorizedAccessException(); } NewsManager.Delete(id); ImageExtensions.DeleteImage(GetNewsImagePath(savedNews.IconName)); return(new DeleteNewsResult()); } catch (Exception ex) { return(new DeleteNewsResult(ex)); } }