Exemplo n.º 1
0
        public async Task <IActionResult> deleteFallowUser(int id)
        {
            var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            if (await _repo.GetUser(userId) == null)
            {
                return(Unauthorized());
            }


            var currentFallow = await _repo.GetFollowUsers(userId);

            var fallowUser = currentFallow.FirstOrDefault(x => x.FollowerId == id);

            _repo.Delete(fallowUser);

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

            return(BadRequest("Failed to delete FallowUser"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> deleteRecipe(int id)
        {
            var user = await _repo.GetUser(int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value));

            if (!user.Recipes.Any(x => x.Id == id))
            {
                return(Unauthorized());
            }

            var recipe = await _repo.GetRecipe(id);

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

                if (result.Result == "ok")
                {
                    recipe.PublicId = null;
                    recipe.PhotoUrl = null;
                }
                else
                {
                    return(BadRequest("Failed to delete Photo"));
                }
            }


            _repo.Delete(recipe);

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

            return(BadRequest("Failed to delete Recipe"));
        }
Exemplo n.º 3
0
 public void Delete(Cook entity)
 {
     _cookRepository.Delete(entity);
 }