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());
            }
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        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"));
        }
Exemplo n.º 5
0
 public AttachmentResponse DeleteAttachment(AttachmentRequest request)
 {
     attachmentRepository.DeleteAttachment(request.AttachmentViewModel.DocumentID);
     return(new AttachmentResponse());
 }