예제 #1
0
 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);
     }
 }
예제 #2
0
        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
                });
            }
        }
예제 #3
0
        public HttpResponseMessage DeletePhoto(int id)
        {
            int rowAffected = _service.DeletePhoto(id);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, rowAffected);

            return(response);
        }
예제 #4
0
        public async Task TestDeletePhoto()
        {
            int idPrueba = 1;

            bool deleted = await photoService.DeletePhoto(idPrueba);

            Assert.IsTrue(deleted);
        }
예제 #5
0
        public IActionResult DeletePic(PhotoDTO pic, int id)
        {
            id = pic.Id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _pService.DeletePhoto(pic);
            return(Ok());
        }
예제 #6
0
        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());
        }
예제 #7
0
        public async Task <IActionResult> DeletePhoto([FromRoute] long id)
        {
            await _photoService.DeletePhoto(id);

            return(NoContent());
        }
예제 #8
0
 public ActionResult DeleteConfirmed(int id)
 {
     _photoService.DeletePhoto(id);
     return(RedirectToAction("Index"));
 }
 public void DeletePhoto(Photo photo)
 {
     _photoService.DeletePhoto(photo);
 }