public ActionResult Details(int id)
        {
            ContactViewModel contact = null;

            var result = _contactsRepo.GetContact(id);

            //If success received
            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <ContactViewModel>();
                readTask.Wait();

                contact = readTask.Result;
            }

            return(View(contact));
        }
        public IActionResult GetContact(string userName)
        {
            var contact = _repo.GetContact(userName);

            if (contact != null)
            {
                return(Ok(contact));
            }
            return(NoContent());
        }
Пример #3
0
        public ViewResult Details(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            //name = "sam";
            var model = _contacts.GetContact(name);

            return(View(model));
        }