public async Task <IActionResult> Delete([FromRoute] string id) { var userId = User.GetUserId(); var attachment = await _repo.GetAttachment(id); if (attachment.CreatedById != userId) { return(Unauthorized()); } var fullPath = $"C:\\Users\\Luka\\Desktop\\BugTracker\\Api\\{attachment.Url}"; System.IO.File.Delete(fullPath); _repo.Delete(attachment); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest()); }