public async Task <ActionResult <Walk> > DeleteWalk([FromHeader] string token, [FromHeader] string email, [FromRoute] string id, [FromHeader] bool isUser) { // if user and not authenticated if (isUser && !await _walkerRepository.Authenticated(token, email)) { return(Unauthorized()); } // is safewalker and not authenticated else if (!isUser && !await _safewalkerRepository.Authenticated(token, email)) { return(Unauthorized()); } var oldWalk = await _walkRepository.Get(id); if (oldWalk == null) { return(NotFound()); } // Check if person is part of the walk if (isUser && oldWalk.UserEmail != email) { return(Unauthorized()); } var walk = await _walkRepository.Delete(id); walk.WithoutWalkerInfo(); return(Ok(walk)); }