public IActionResult Delete(int id, int idThing) { WebRequest request = WebRequest.Create(_configuration.GetValue <string>("BackendUrl") + "api/thing/" + id + "/" + idThing); request.Method = "Delete"; request.GetResponse(); List <ThingViewModel> things; request = WebRequest.Create(_configuration.GetValue <string>("BackendUrl") + "api/thing/" + id); request.Method = "Get"; using (var s = request.GetResponse().GetResponseStream()) { using (var sr = new StreamReader(s)) { var contributorsAsJson = sr.ReadToEnd(); things = JsonConvert.DeserializeObject <List <ThingViewModel> >(contributorsAsJson); } } ShopThingsViewModel shopThingsModel = new ShopThingsViewModel { idShop = id, things = things }; return(View("Index", shopThingsModel)); }
public async Task <IActionResult> AddNewThing(AddThingViewModel model, int id) { if (ModelState.IsValid) { var user = await GetCurrentUserAsync(); var userId = user?.Id; WebRequest request = WebRequest.Create(_configuration.GetValue <string>("BackendUrl") + "api/thing/" + id + "/" + model.name + "/" + model.kind + "/" + model.price); request.Method = "Post"; request.GetResponse(); List <ThingViewModel> things; request = WebRequest.Create(_configuration.GetValue <string>("BackendUrl") + "api/thing/" + id); request.Method = "Get"; using (var s = request.GetResponse().GetResponseStream()) { using (var sr = new StreamReader(s)) { var contributorsAsJson = sr.ReadToEnd(); things = JsonConvert.DeserializeObject <List <ThingViewModel> >(contributorsAsJson); } } ShopThingsViewModel shopThingsModel = new ShopThingsViewModel { idShop = id, things = things }; return(View("Index", shopThingsModel)); } return(View(model)); }