public async Task <IActionResult> AddFriend(string id) { if (string.IsNullOrEmpty(id)) { ModelState.AddModelError("null_id", "id string can't be empty."); return(BadRequest(ModelState)); } var user = await _profileService.QueryUserOrDefault(id, User); if (user == null) { ModelState.AddModelError("null_profile", "can't find user profile with specified id."); return(BadRequest(ModelState)); } var result = await _profileService.AddFriend(id, User); if (result == false) { ModelState.AddModelError("null_profile", "can't find user profile with specified id."); return(BadRequest(ModelState)); } return(Ok()); }
public ActionResult Message() { profileService.AddFriend(1, 2); return(RedirectToAction("Home", "Profile")); }