Esempio n. 1
0
        //
        // GET: /Contacts/Details/5

        public ActionResult Details(int id = 0)
        {
            Contact contact = repo.Get(c => c.ID == id);

            if (contact == null)
            {
                return(HttpNotFound());
            }
            return(View(contact));
        }
Esempio n. 2
0
 public ActionResult <string> Get(string id)
 {
     try
     {
         var guid    = Guid.Parse(id);
         var contact = ContactsRepository.Get(guid);
         if (contact != null)
         {
             var contactModel = GetContactModel(contact);
             return(Content(contactModel.ToString()));
         }
         return("Not Found");
     }
     catch
     {
         return("Id is Incorrect");
     }
 }
Esempio n. 3
0
        //
        // GET api/contacts/guid
        //
        public Contact Get(Guid id)
        {
            var contact = repo.Get(id);

            if (contact == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(contact);
        }
Esempio n. 4
0
        //
        // GET api/contacts/guid
        //
        public Customer Get(string id)
        {
            var contact = repo.Get(id);

            if (contact == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(contact);
        }
 public IActionResult Get()
 {
     try
     {
         var repoContacts = new ContactsRepository(_context);
         var contacts     = repoContacts.Get();
         return(Ok(contacts));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public IActionResult Get(int id)
 {
     try
     {
         var repoContacts = new ContactsRepository(_context);
         var contact      = repoContacts.Get(id);
         if (contact is null)
         {
             return(NotFound());
         }
         return(Ok(contact));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Esempio n. 7
0
 public IEnumerable <Contact> Get()
 {
     return(_repo.Get());
 }
Esempio n. 8
0
        private async void OnWindowLoad(object sender, RoutedEventArgs e)
        {
            var contacts = await repository.Get();

            contacts.ForEach(c => contactListView.Items.Add(c));
        }