public async Task <IActionResult> DeleteMessage(int userId, int id)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var messageFromRepo = await _repo.GetMessage(id);

            if (messageFromRepo.RecipientId == userId)
            {
                messageFromRepo.RecipientDelete = true;
            }

            if (messageFromRepo.SenderId == userId)
            {
                messageFromRepo.SenderDelete = true;
            }

            if (messageFromRepo.SenderDelete && messageFromRepo.RecipientDelete)
            {
                _repo.Remove(messageFromRepo);
            }

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            return(BadRequest("Error occurred during deleting the message"));
        }
        public async Task <IActionResult> deletePhoto(int userId, int photoId)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var userFromRepo = await _repo.GetUser(userId);

            if (!userFromRepo.Photos.Any(p => p.ID == photoId))
            {
                return(Unauthorized());
            }

            var photo = await _repo.GetPhoto(photoId);

            if (photo.IsMain)
            {
                return(BadRequest("It's can not be deleted. The photo is the main photo!"));
            }

            if (photo.PublicId != null)
            {
                var deletePram = new DeletionParams(photo.PublicId);
                var result     = _cloudinary.Destroy(deletePram);

                if (result.Result == "ok")
                {
                    _repo.Remove(photo);
                }
            }

            _repo.Remove(photo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            return(BadRequest("Error at deleting the photo"));
        }