Example #1
0
        public async Task <IActionResult> DeletePhoto(int id)
        {
            var photoFromRepo = await _repo.GetPhoto(id);

            var response = await _repo.DeletePhoto(photoFromRepo);

            if (response == false)
            {
                return(BadRequest());
            }

            return(Ok(photoFromRepo));
        }
Example #2
0
        public async Task <IActionResult> DeletePhoto(int UserId, int Id)
        {
            if (UserId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            var PhotoFromRepo = await _repo.GetPhoto(Id);

            var DeleteParam = new DeletionParams(PhotoFromRepo.PublicId);
            var Result      = _Cloudinary.Destroy(DeleteParam);

            if (Result.Result == "ok")
            {
                _repo.DeletePhoto(Id);
            }
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("could not Delete Photo "));
        }