public async Task <IActionResult> DeleteFile(int AttachmentID) { var result = _attachmentRepository.Find(p => p.AttachmentID == AttachmentID); if (result != null) { if (_appSettings.UploadFileToDataBase == "0") { var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "Upload"); var filePath = Path.Combine(uploads, result.FileName); if (!System.IO.File.Exists(filePath)) { return(NotFound()); } System.IO.File.Delete(filePath); return(Ok()); } else { await _attachmentRepository.DeleteAttachment(AttachmentID); return(Ok()); } } else { return(NotFound()); } }
public IActionResult Delete(long id) { _logger.LogInformation(LoggingEvents.DeleteItem, "Delete Attachment", "Id ", id); var attachment = _attachmentRepository.Attachments.FirstOrDefault(a => a.Id == id); if (attachment == null) { _logger.LogInformation(LoggingEvents.DeleteItem, "Delete Attachment", "Not Found Id ", id); return(NotFound()); } _attachmentRepository.DeleteAttachment(id); return(new NoContentResult()); }
public void DeleteChat(Guid id) { try { _attachRepository.DeleteAttachment(id); } catch (SqlException exception) { var response = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(exception.Message) }; throw new HttpResponseException(response); } }
public async Task <IActionResult> Delete(int supplierId, int Id) { try { var Attachment = await _repository.GetAttachmentAsync(supplierId, Id); if (Attachment == null) { return(NotFound()); } if (await _repository.DeleteAttachment(Attachment)) { return(Ok()); } } catch (Exception e) { _logger.LogError(e, e.Message); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest("Failed to delete the Attachment")); }
public AttachmentResponse DeleteAttachment(AttachmentRequest request) { attachmentRepository.DeleteAttachment(request.AttachmentViewModel.DocumentID); return(new AttachmentResponse()); }