// GET: TaxInformations public async Task <ActionResult> Index() { taxOfficeModel taxOffice = new taxOfficeModel(); using (var client = new HttpClient()) { setClientSettings(client); //Get list of Unions HttpResponseMessage Res = await client.GetAsync("api/taxOfficeModels"); taxOffice.taxOfficeList = new List <taxOfficeModel>(); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var UnionResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list taxOffice.taxOfficeList = JsonConvert.DeserializeObject <List <taxOfficeModel> >(UnionResponse); } } return(View(taxOffice)); }
public IHttpActionResult PuttaxOfficeModel(int id, taxOfficeModel taxOfficeModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != taxOfficeModel.Id) { return(BadRequest()); } db.Entry(taxOfficeModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!taxOfficeModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> Index(taxOfficeModel tax) { try { if (ModelState.IsValid) { using (var client = new HttpClient()) { setClientSettings(client); //serialize object to Json and create the HttpContent tax.active = true; HttpContent content = new StringContent(JsonConvert.SerializeObject(tax)); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); //Sending request to find web api REST service resource GetAllEmployees using HttpClient HttpResponseMessage Res = await client.PostAsync("api/taxOfficeModels/", content); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var UnionResponse = Res.Content.ReadAsStringAsync().Result; } ModelState.Clear(); } return(RedirectToAction("Index")); } using (var client = new HttpClient()) { setClientSettings(client); //Get list of Unions HttpResponseMessage Res = await client.GetAsync("api/taxOfficeModels"); tax.taxOfficeList = new List <taxOfficeModel>(); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var taxResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list tax.taxOfficeList = JsonConvert.DeserializeObject <List <taxOfficeModel> >(taxResponse); } } return(View(tax)); } catch { return(View(tax)); } }
public IHttpActionResult GettaxOfficeModel(int id) { taxOfficeModel taxOfficeModel = db.taxOfficeModels.Find(id); if (taxOfficeModel == null) { return(NotFound()); } return(Ok(taxOfficeModel)); }
public IHttpActionResult PosttaxOfficeModel(taxOfficeModel taxOfficeModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.taxOfficeModels.Add(taxOfficeModel); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = taxOfficeModel.Id }, taxOfficeModel)); }
public IHttpActionResult DeletetaxOfficeModel(int id) { taxOfficeModel taxOfficeModel = db.taxOfficeModels.Find(id); if (taxOfficeModel == null) { return(NotFound()); } db.taxOfficeModels.Remove(taxOfficeModel); db.SaveChanges(); return(Ok(taxOfficeModel)); }
public async Task <ActionResult> Edit(int id, taxOfficeModel taxOffice) { try { if (ModelState.IsValid) { using (var client = new HttpClient()) { setClientSettings(client); //serialize object to Json and create the HttpContent HttpContent content = new StringContent(JsonConvert.SerializeObject(taxOffice)); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); //Sending request to find web api REST service resource GetAllEmployees using HttpClient HttpResponseMessage Res = await client.PutAsync("api/taxOfficeModels/" + id, content); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var UnionResponse = Res.Content.ReadAsStringAsync().Result; } } ModelState.Clear(); return(RedirectToAction("Index")); } else { return(View(taxOffice)); } } catch { return(RedirectToAction("Index")); } }
public async Task <ActionResult> Edit(int id) { taxOfficeModel taxOffice = new taxOfficeModel(); using (var client = new HttpClient()) { setClientSettings(client); //Sending request to find web api REST service resource GetAllEmployees using HttpClient HttpResponseMessage Res = await client.GetAsync("api/taxOfficeModels/" + id); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var EmpResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list taxOffice = JsonConvert.DeserializeObject <taxOfficeModel>(EmpResponse); } return(View(taxOffice)); } }