public static void Main() { addclass ac = new addclass(); Console.WriteLine("{0} + {1} = {2}", 4, 7, ac.Add(4, 7)); Console.WriteLine("{0} + {1} = {2}", 7.2, 8.5, ac.Add(7.2, 8.5)); }
//GET REQUEST //public ActionResult AddClass() //{ // List<addclass> Teacherlist = new List<addclass>(); // HttpClient client = new HttpClient(); // var result = client.GetAsync("http://www.Edujinni.com/classdetailslist").Result; // if (result.IsSuccessStatusCode) // { // Teacherlist = result.Content.ReadAsAsync<List<addclass>>().Result; // } // return View(Teacherlist); //} //[HttpPost] //public ActionResult AddClass(addclass add) //{ // using (var client = new HttpClient()) // { // client.BaseAddress = new Uri("http://www.Edujinni.com/addingclassdetails"); // //HTTP POST // var postTask = client.PostAsJsonAsync<addclass>("add", add); // postTask.Wait(); // var result = postTask.Result; // if (result.IsSuccessStatusCode) // { // // return RedirectToAction("Index"); // Console.WriteLine("okk"); // } // else // { // Console.WriteLine("error"); // } // } // ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); // return View(add); //} //public ActionResult AddClass() //{ // return View(); //} public async Task <ActionResult> addclass(addclass add) { addclass addd = new addclass(); //add.gettingdetails(); //add.addingdetails(); HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://www.edujinni.in/"); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // List all Names. HttpResponseMessage response = client.GetAsync("classNames/classDetailsList").Result; // Blocking call! string cname = response.Content.ReadAsStringAsync().Result; var pname = response.RequestMessage.ToString().ToList(); var tname = response.Headers.ToList(); string kname = response.IsSuccessStatusCode.ToString(); string lname = response.ReasonPhrase.ToString(); string fname = response.StatusCode.ToString(); string mname = Response.StatusCode.ToString(); string rname = response.Version.ToString(); string gname = Response.Output.ToString(); string cfname = Response.Status.ToString(); string llname = Response.Buffer.ToString(); string kkname = Response.BufferOutput.ToString(); string laname = Response.OutputStream.ToString(); // string nn = response.TryGetContentValue(out cname).ToString(); if (response.IsSuccessStatusCode) { //string s = nn; SelectList list = new SelectList(lname, "class_name"); //string s = list.ToString(); ViewBag.class_name = list; } else { //Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } return(View()); }