public HttpResponseMessage Post([FromBody] EquipVendorDTO equipVendor) { EqVendors.AddOrUpdate(equipVendor); string tmp = string.Format($"{equipVendor.EquipVendorID} has been saved"); HttpResponseMessage msg = Request.CreateResponse(HttpStatusCode.OK, tmp); string url = Url.Link("DefaultApi", new { id = equipVendor.EquipVendorID }); msg.Headers.Location = new Uri(url); return(msg); }
public HttpResponseMessage Get(int id) { EquipVendorDTO vendorDTO = EqVendors.Get(id); if (vendorDTO == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "NotFound")); } return(Request.CreateResponse(HttpStatusCode.OK, vendorDTO)); }
public async Task <ActionResult> Delete(EquipVendorDTO equip) { var client = new HttpClient(); HttpResponseMessage response = await client.DeleteAsync( $"http://localhost:50494/api/Warehouse/{equip}"); String stCode = "410"; if (response.StatusCode.ToString() == stCode) { TempData["message"] = string.Format($"{equip.EquipVendorName} was deleted!"); } return(RedirectToAction("List")); }
public HttpResponseMessage Delete([FromBody] EquipVendorDTO equipVendor) { if (equipVendor != null) { EqVendors.Delete(equipVendor); string tmp = string.Format($"{equipVendor.EquipVendorID} has been deleted"); HttpResponseMessage msg = Request.CreateResponse(HttpStatusCode.OK, tmp); string url = Url.Link("DefaultApi", new { id = equipVendor.EquipVendorID }); msg.Headers.Location = new Uri(url); return(msg); } //else // HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Gone); return(null); }
public async Task <ActionResult> AddOrUpdate(EquipVendorDTO equip) { var client = new HttpClient(); var response = await client.PostAsJsonAsync("http://localhost:50494/api/Warehouse", equip); if (response.IsSuccessStatusCode) { // Deserialize the updated product from the response body. var equipT = await response.Content.ReadAsStringAsync(); var equipDeS = JsonConvert.DeserializeObject <String>(equipT); if (equip != null) { TempData["message"] = string.Format($"{equip.EquipVendorName} is exists!"); } } return(RedirectToAction("List")); }