private void btnDelete_Click(object sender, EventArgs e) { try { _photoService.DeletePhoto(_photo); Context.Response.Redirect("AdminPhotos.aspx" + base.GetBaseQueryString() + "&AlbumId=" + this._albumId); } catch (Exception ex) { ShowError("Error deleting file: " + ex.Message); } }
public IActionResult DeletePhoto(FileToDeleteDto fileToDeleteDto) { try { _photoService.DeletePhoto(fileToDeleteDto.PhotoId); var responseString = "Photo was deleted successfully."; return(Ok(new { responseString })); } catch (InvalidOperationException invalidOperationException) { return(BadRequest(new { invalidOperationException.Message })); } catch (Exception exeption) { return(new ObjectResult(new { Error = exeption.Message }) { StatusCode = StatusCodes.Status500InternalServerError }); } }
public HttpResponseMessage DeletePhoto(int id) { int rowAffected = _service.DeletePhoto(id); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, rowAffected); return(response); }
public async Task TestDeletePhoto() { int idPrueba = 1; bool deleted = await photoService.DeletePhoto(idPrueba); Assert.IsTrue(deleted); }
public IActionResult DeletePic(PhotoDTO pic, int id) { id = pic.Id; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _pService.DeletePhoto(pic); return(Ok()); }
public void DeletePhoto_WhenFound_DeletesPhoto() { var vehicleId = 1; var photo = new Photo { VehicleId = vehicleId, ImageUrl = "TEST", IsMain = true }; var result = _photoService.SavePhoto(photo); var photosCount = _unitOfWork.Photos.GetAllByVehicleId(vehicleId).Count(); _photoService.DeletePhoto(result.Id); Assert.NotEqual(photosCount, _unitOfWork.Photos.GetAllByVehicleId(vehicleId).Count()); }
public async Task <IActionResult> DeletePhoto([FromRoute] long id) { await _photoService.DeletePhoto(id); return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { _photoService.DeletePhoto(id); return(RedirectToAction("Index")); }
public void DeletePhoto(Photo photo) { _photoService.DeletePhoto(photo); }