Пример #1
0
        public async Task <ActionResult> AddNewUser()
        {
            var model = new UserModel
            {
                UserName  = "******",
                FirstName = "Pooja",
                LastName  = "Keshwala",
                Email     = "*****@*****.**",
                Contact   = "789456123",
                UserId    = 0 // Add mode
            };

            var uri    = "SaveUser";
            var result = await _client.PostRequest <BaseApiResponse, UserModel>(model, uri);

            if (result.Success)
            {
                // Handle success here
            }
            else
            {
                // Handle error here
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create(UserModel userModel)
        {
            try
            {
                var url    = "api/CreateNewUser";
                var result = new BaseApiResponse();
                result = await _client.PostRequest <BaseApiResponse, UserModel>(userModel, url);

                if (result.Success)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }