Ejemplo n.º 1
0
 public Customer GetCustomer()
 {
     Customer c = new Customer();
     c.CustomerName = "James";
     c.Address = "UK";
     c.Age = 25;
     return c;
 }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            CustomerBAL b = new CustomerBAL();
            Customer c = b.GetCustomer();
            Customer d = new Customer();
            d.CustomerName = "alex";

            List<Customer> customers = new List<Customer>();
            customers.Add(c);
            customers.Add(d);
               // return View(customers);
            return View();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var    client = new HttpClient();
            string url    = "http://*****:*****@gmail.com",
                firstName = "anna",
                lastName  = "anna"
                            //  customer=cust
            };
            WebApplication2.Models.CustomerContact cont2 = new WebApplication2.Models.CustomerContact()
            {
                email     = "*****@*****.**",
                firstName = "nikos",
                lastName  = "nikos"
            };


            var ll = new List <CustomerContact>();

            ll.Add(cont);
            ll.Add(cont2);

            //  cust.customerContact = ll;

            WebApplication2.Models.Customer cust = new WebApplication2.Models.Customer()
            {
                customerContact   = ll,
                NumberOfEmployees = 33,
                Title             = "president"
            };

            HttpResponseMessage response = new HttpResponseMessage();

            switch (int.Parse(choice))
            {
            case 1:
                response = client.GetAsync(url).Result;
                WebApplication2.Models.Customer[] data = JsonConvert.DeserializeObject <WebApplication2.Models.Customer[]>(response.Content.ReadAsStringAsync().Result);

                break;

            case 2:
                response = client.PostAsJsonAsync <WebApplication2.Models.Customer>(url, cust).Result;
                Console.WriteLine(response.ToString());
                break;

            case 3:
                response = client.PostAsJsonAsync(url, cust).Result;
                Console.WriteLine(response.ToString());
                break;
                //case 4:
                // response = client.DeleteAsync()
            }
        }