public IActionResult Unfollow(long id) { var loggedInUserId = HttpContext.Session.GetString("LoggedInUserId"); if (loggedInUserId == null) { return(StatusCode(401)); } User userForFollow = _userData.GetById(id); User loggedInUser = _userData.GetById(long.Parse(loggedInUserId)); if (loggedInUser == null || userForFollow == null) { return(BadRequest()); } if (_followData.Exist(loggedInUser.Id, userForFollow.Id)) { Follow follow = new Follow(); follow.Follower = loggedInUser; follow.Following = userForFollow; _followData.Delete(follow); } var contentType = Request.ContentType; if (contentType != null) { return(NoContent()); } return(Json("Success")); }