Esempio n. 1
0
        public async Task <IActionResult> DeleteProfile(int id)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var user = await _repo.GetUser(id);

            if (user == null)
            {
                return(BadRequest("User Already Deleted"));
            }


            _repo.DeleteUser(id);
            _repo.Delete <User>(user);

            if (await _repo.SaveAll())
            {
                return(Ok(true));
            }
            return(BadRequest("Failed to delete account"));
        }