Exemplo n.º 1
0
        public async Task <IActionResult> deleteWish(string username, int id)
        {
            var user = await _repo.GetUser(username);

            if (user.UserName.ToString() != User.FindFirst(ClaimTypes.NameIdentifier).Value)
            {
                return(Unauthorized());
            }
            var wishToRemove = await _wishRepo.GetWish(id);

            user.UserWishes.Remove(wishToRemove);
            _wishRepo.RemoveWish(wishToRemove);
            if (await _repo.SaveAll())
            {
                return(Ok("Deleted"));
            }
            return(BadRequest("Problem with removing wish"));
        }