public async Task <List <EmployModel> > GetAllEmploy() { using (var client5 = new HttpClient()) { client5.BaseAddress = new Uri("http://www.ist.rit.edu/"); client5.DefaultRequestHeaders.Accept.Clear(); client5.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { HttpResponseMessage response = await client5.GetAsync("api/employment/coopTable/coopInformation", HttpCompletionOption.ResponseHeadersRead); response.EnsureSuccessStatusCode(); var data = await response.Content.ReadAsStringAsync(); var rtnResults = JsonConvert.DeserializeObject <Dictionary <string, List <EmployModel> > >(data); List <EmployModel> employList = new List <EmployModel>(); EmployModel employ = new EmployModel(); foreach (KeyValuePair <string, List <EmployModel> > kvp in rtnResults) { foreach (var item in kvp.Value) { employList.Add(item); } } return(employList); } catch (HttpRequestException hre) { var msg = hre.Message; List <EmployModel> employList = new List <EmployModel>(); return(employList); //return "HttpRequestException"; } catch (Exception ex) { var msg = ex.Message; List <EmployModel> employList = new List <EmployModel>(); return(employList); //return "Exception"; ; } } }
public ActionResult AddOrEdit(EmployModel employModel) { DynamicParameters param = new DynamicParameters(); param.Add("@EmployID", employModel.EmployID); param.Add("@Name", employModel.Name); param.Add("@City", employModel.City); param.Add("@Age", employModel.Age); param.Add("@Salary", employModel.Salary); try { DapperORM.ExecuteWithoutReturn("EmployAddOrEdit", param); } catch (Exception) { throw; } return(RedirectToAction("Index")); }
private void btnSearch_Click(object sender, EventArgs e) { popeGrid1.DataSource = EmployModel.GetList(); }