public IActionResult Follow(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)) { return(BadRequest()); } Follow follow = new Follow(); follow.Follower = loggedInUser; follow.Following = userForFollow; follow = _followData.Add(follow); var contentType = Request.ContentType; if (contentType != null) { if (contentType.Equals("application/json")) { return(Json(follow)); } else if (contentType.Equals("text/html")) { //return RedirectToAction(nameof(GetById), id); } else if (contentType.Equals("application/x-www-form-urlencoded")) { //return RedirectToAction(nameof(GetById), id); } return(StatusCode(415)); } return(Json("Success")); }