public ActionResult Delete(int id) { //Find picture by ID var pictureModel = _pictureManager.GetPictureByID(id); //TODO: Tell PictureManager to delete Picture var isDeleted = _pictureManager.DeletePicture(id); //TODO: If picture is deleted, do the following if (isDeleted) { //TODO: Delete picture from file //Find the File to be deleted var filePath = Server.MapPath(pictureModel.FilePath); //Delete the picture from the file. System.IO.File.Delete(filePath); //TODO: Return to index page with success alert TempData[Alert.AlertMsgKey] = "Picture Deleted Successfully"; TempData[Alert.AlertTypeKey] = Alert.AlertSuccess; return(RedirectToAction("Index", "Picture", new { albumID = pictureModel.AlbumID, alert = true })); } //TODO: If picture failed to delete, return to index page with danger alert TempData[Alert.AlertMsgKey] = "Sorry, Picture couldn't be deleted. Pls try again."; TempData[Alert.AlertTypeKey] = Alert.AlertSuccess; return(RedirectToAction("Index", "Picture", new { albumID = pictureModel.AlbumID, alert = true })); }
private async Task TakePicture() { _pictureManager.DeletePicture(_media.Path); Image = null; _manager = new CameraManager(_mediaPicker); var file = await _manager.TakePhotoFromCamera(); ConfirmPage._mediFile = file; Image = ImageSource.FromStream(() => file.Source); }