예제 #1
0
        public async Task <IActionResult> Create([Bind("FriendUniqueName")] FriendViewModel friendViewModel)
        {
            if (ModelState.IsValid)
            {
                string userId = _userManager.GetUserId(User);
                bool   result = await _friendRepository
                                .AddFriendAsync(friendViewModel.FriendUniqueName, userId);

                if (!result)
                {
                    return(BadRequest());
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(friendViewModel));
        }