private async Task DeleteImage(Collection collection) { if (!string.IsNullOrEmpty(collection.ImagePath)) { await blobService.DeleteBlobAsync(Path.GetFileName(collection.ImagePath)); } }
private async Task DeleteCover(int collectionId) { var collection = collectionService.GetById(collectionId); if (collection != null && !string.IsNullOrEmpty(collection.ImagePath)) { await blobService.DeleteBlobAsync(Path.GetFileName(collection.ImagePath)); } }
public async Task <IActionResult> Edit(ApplicationUserEditViewModel model) { if (!ModelState.IsValid) { return(View(model)); } if (model.Image != null) { string fileName = await _appUserService.GetImageNameByIdAsync(model.Id); await _blobService.DeleteBlobAsync(fileName); var result = await _blobService.CreateBlobAsync(model.Image); if (result.Success) { model.ImageName = result.NewFileName; } else { ModelState.AddModelError(nameof(model.Image), "Sólo se admiten tipos de archivos PNG o JPG."); return(View(model)); } } if (await _appUserService.UpdateAsync(model)) { var oMessage = new MessageViewModel($"El usuario <a href='#' class='alert-link'>{model.Name}</a> ha sido modificado exitosamente!", "alert-success"); TempData.PutObject("Message", oMessage); } else { var oMessage = new MessageViewModel("Hubo un problema y no se modificó el recurso.", "alert-danger"); TempData.PutObject("Message", oMessage); } return(RedirectToAction(nameof(Index))); }
public async Task <Unit> Handle(DeleteCommunityCommand request, CancellationToken cancellationToken) { if (!request.Community.Image.Equals($"{nameof(Community)}/no-image.jpg")) { await _blobService.DeleteBlobAsync(request.Community.Image); } await _communityService.DeleteCommunityAsync(request.Community); return(Unit.Value); }
public async Task Delete(long videoId) { var video = await _videoRepository.GetByIdAsync(videoId); if (video == null) { throw new ArgumentNullException(nameof(videoId), "video not found"); } await _videoRepository.Remove(video); await _blobService.DeleteBlobAsync(video.FileName); }
public async Task Delete(long imageId) { var image = await _imageRepository.GetByIdAsync(imageId); if (image == null) { throw new ObjectNotFoundException(nameof(imageId), "image not found"); } await _imageRepository.Remove(image); await _blobService.DeleteBlobAsync(image.FileName); }
public async Task <IActionResult> DeleteEquipmentMediaAsync(DeleteEquipmentMediaViewModel model) { if (!ModelState.IsValid) { return(Json(new { error = $"{GlobalConstants.ERROR_ACTION_PREFIX} delete {ENTITY_NAME}." })); } EquipmentBlobResponse _RetrieveResponse = await __EquipmentBlobManager.GetByUIDAsync(model.UID); if (!_RetrieveResponse.Success) { return(Json(new { error = $"{GlobalConstants.ERROR_ACTION_PREFIX} delete {ENTITY_NAME}." })); } await __BlobService.DeleteBlobAsync(_RetrieveResponse.Blob.Name); await __EquipmentBlobManager.DeleteAsync(_RetrieveResponse.UID); await __BlobManager.DeleteAsync(_RetrieveResponse.BlobUID); return(RedirectToAction("DetailsView", "Equipment", new { Area = "Equipment", equipmentUID = _RetrieveResponse.EquipmentUID, successMessage = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} removed {ENTITY_NAME}." })); }
public async Task <IActionResult> DeleteProfileImage([FromRoute] int fileID) { try { // Find File var blobFile = await _dbContext.BlobFiles.FindAsync(fileID); if (blobFile == null) { return(NotFound(new { message = "File Not Found" })); } await _blobService.DeleteBlobAsync(blobFile); // Delete Blob Files From Database _dbContext.BlobFiles.Remove(blobFile); // Save Change to Database await _dbContext.SaveChangesAsync(); // Return Ok Status return(Ok(new { result = blobFile, message = "File Successfully Deleted" })); } catch (Exception e) { // Return Bad Request If There Is Any Error return(BadRequest(new { error = e })); } }
public IActionResult Delete(string blobName) { _blobServie.DeleteBlobAsync(blobName); return(RedirectToAction("Index", "Container")); }
public async Task <IActionResult> DeleteFileAsync(string blobName) { await _blobService.DeleteBlobAsync(blobName); return(Ok()); }
public async Task <IActionResult> Delete(string name) { await blobService.DeleteBlobAsync(name); return(Ok()); }