public async Task <ActionResult> Delete(int id) { var attractionReview = await _attractionRepo.GetAttractionReview(id); if (attractionReview == null) { return(NotFound()); } if (!await MatchAppUserWithToken((int)attractionReview.AppUserId)) { return(Unauthorized()); } _attractionRepo.Delete(attractionReview); await _attractionRepo.SaveAll(); foreach (var photo in attractionReview.Photos) { _attractionRepo.Delete(photo); var deletingResult = this._imageFileStorageManager.DeleteImageFile(photo); if (!string.IsNullOrEmpty(deletingResult.Error)) { this._logger.LogError(deletingResult.Error); } } await _attractionRepo.SaveAll(); return(Ok()); }
public IActionResult Delete(int id) { if (id > 0) { Attraction newAttraction = _attractionRepository.Delete(id); } return(RedirectToAction("index")); }
public async Task <ActionResult> Delete(int id) { var attraction = await _attractionRepo.GetAttraction(id); if (attraction == null) { return(NotFound()); } if (!await MatchAppUserWithToken((int)attraction.AppUserId)) { return(Unauthorized()); } //Delete reviews first (to delete image files) var allReviewPhotos = await _attractionRepo.GetAllReviewPhotosForAttraction(attraction.Id); _attractionRepo.Delete(attraction); await _attractionRepo.SaveAll(); foreach (var photo in attraction.Photos) { _attractionRepo.Delete(photo); var task = this._imageFileStorageManager.DeleteImageFileAsync(photo); // var deletingResult = this._imageFileStorageManager.DeleteImageFile(photo); // if (!string.IsNullOrEmpty(deletingResult.Error)) // this._logger.LogError(deletingResult.Error); } foreach (var reviewPhoto in allReviewPhotos) { _attractionRepo.Delete(reviewPhoto); var task = this._imageFileStorageManager.DeleteImageFileAsync(reviewPhoto); } await _attractionRepo.SaveAll(); return(Ok()); }
public void Delete(int id) { _attractionRepository.Delete(id); _unitOfWork.Save(); }
public void DeleteAtrraction(Expression <Func <Attraction, bool> > where) { _iRespository.Delete(where); }