// GET: BGamesController/Delete/5 public async Task <ActionResult> Delete(string id) { BGames bgames = new BGames(); var response = await _service.Client.GetAsync($"/api/bgames/{id}"); if (response.IsSuccessStatusCode) { var pobraneGry = response.Content.ReadAsStringAsync().Result; bgames = JsonConvert.DeserializeObject <BGames>(pobraneGry); } return(View(bgames)); }
public IActionResult Update(string id, BGames bgameIn) { //Console.WriteLine(bgameIn.Count); var gdata = Newtonsoft.Json.JsonConvert.SerializeObject(bgameIn); Console.WriteLine(gdata); var bgame = _bgameService.Get(id); if (bgame == null) { return(NotFound()); } _bgameService.Update(id, bgameIn); return(NoContent()); }
public async Task <ActionResult> Edit(string id, IFormCollection collection) { BGames game = new BGames(); game.oid = collection["oid"]; game.name = collection["name"]; game.briefdescribe = collection["briefdescribe"]; game.image = collection["image"]; game.minPlayers = Convert.ToInt32(collection["minPlayers"]); game.maxPlayers = Convert.ToInt32(collection["maxPlayers"]); game.playingTime = Convert.ToInt32(collection["playingTime"]); game.yearPublished = Convert.ToInt32(collection["yearPublished"]); game.Rating = Convert.ToInt32(collection["Rating"]); game.type = collection["type"]; game.itemtype = collection["itemtype"]; game.ilosc = Convert.ToInt32(collection["ilosc"]); game.cena = Convert.ToInt32(collection["cena"]); game.describe = collection["describe"]; var jdata = JsonConvert.SerializeObject(game); var httpContent = new StringContent(jdata, Encoding.UTF8, "application/json"); Console.WriteLine("---- PutAsync ------"); var httpResponse = await _service.Client.PutAsync($"/api/BGames/{id}", httpContent); Console.WriteLine("---- PutAsync END------"); Console.WriteLine(httpResponse); try { return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void Remove(BGames bgameIn) => _bgames.DeleteOne(games => games.oid == bgameIn.oid);
// public void Update(string id, BGames bookIn) => public void Update(string id, BGames bookIn) => _bgames.ReplaceOne(games => games.oid == id, bookIn);
public BGames Create(BGames bgame) { _bgames.InsertOne(bgame); return(bgame); }
public ActionResult <BGames> Create(BGames bgame) { _bgameService.Create(bgame); return(CreatedAtRoute("GetBook", new { id = bgame.oid.ToString() }, bgame)); }