Exemple #1
0
        public IActionResult CreateSave(FriendsList friendsList, string?id)
        {
            var identidade = _userManager.GetUserId(User);

            if (id == null)
            {
                return(NotFound());
            }

            if (!_baseContext.FriendsExist(id))
            {
                if (identidade.Contains(id))
                {
                    return(RedirectToAction(nameof(Index)));
                }
                friendsList.ApplicationUserId = id;
                var post = _baseApi.Consumer.PostAsJsonAsync <FriendsList>("api/FriendsListsApi", friendsList);
                post.Wait();

                var result = post.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.Text = "Friend has already been added to the list!!";
            return(RedirectToAction(nameof(Index)));
        }