public async Task <ActionResult> CompanyDBList() { CompanyDBDataModel model = new CompanyDBDataModel(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:49750/"); HttpResponseMessage response = await client.GetAsync("api/CompanyDB/CompanyDBList"); if (response.IsSuccessStatusCode) { model.companydbList = response.Content.ReadAsAsync <List <CompanyDBDTO> >().Result; } HttpResponseMessage response2 = await client.GetAsync("api/Company/ActiveCompanyList"); if (response2.IsSuccessStatusCode) { model.companyList = response2.Content.ReadAsAsync <List <CompanyDTO> >().Result; } return(View(model)); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> DeleteCompanyDB(CompanyDBDataModel model) { try { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:49750/"); HttpResponseMessage response = await client.PostAsJsonAsync("api/CompanyDB/DeleteCompanyDB", model.companydbDTO); if (response.IsSuccessStatusCode) { return(RedirectToAction("CompanyDBList", "Home")); } } } catch (Exception e) { Debug.WriteLine(e.Message); } return(RedirectToAction("CompanyDBInfoById", "Home", new { id = model.companydbDTO.CompanyDBId })); }
public async Task <ActionResult> CompanyDBInfoById(int id) { CompanyDBDataModel model = new CompanyDBDataModel(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:49750/"); HttpResponseMessage response = await client.GetAsync("api/CompanyDB/CompanyDBDataById/?CompanyDBId=" + id); if (response.IsSuccessStatusCode) { model.companydbDTO = response.Content.ReadAsAsync <CompanyDBDTO>().Result; return(View(model)); } } } catch (Exception e) { Debug.WriteLine(e.Message); } return(RedirectToAction("CompanyDBList", "Home")); }