public IHttpActionResult Put([FromBody] FigureItemsByPlayer figureItemsByPlayer) { try { using (var entities = new GreatWarriorEntities()) { var editFigureItem = entities.FigureItemsByPlayers.SingleOrDefault( f => f.Player_Email == figureItemsByPlayer.Player_Email && f.Figure_Name == figureItemsByPlayer.Figure_Name && f.FigureItem_Name == figureItemsByPlayer.FigureItem_Name); if (editFigureItem == null) { return(Content(HttpStatusCode.NotFound, false)); } editFigureItem.Player_Email = figureItemsByPlayer.Player_Email; editFigureItem.Figure_Name = figureItemsByPlayer.Figure_Name; editFigureItem.FigureItem_Name = figureItemsByPlayer.FigureItem_Name; editFigureItem.Item_Level = figureItemsByPlayer.Item_Level; editFigureItem.Figure_Attack = figureItemsByPlayer.Figure_Attack; editFigureItem.Figure_Defense = figureItemsByPlayer.Figure_Defense; entities.SaveChanges(); return(Content(HttpStatusCode.OK, true)); } } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, ex)); } }
public IHttpActionResult Post([FromBody] FigureItemsByPlayer figureItemsByPlayer) { try { using (var entities = new GreatWarriorEntities()) { entities.FigureItemsByPlayers.Add(figureItemsByPlayer); entities.SaveChanges(); return(Content(HttpStatusCode.OK, true)); } } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, ex)); } }
public IHttpActionResult Delete([FromBody] FigureItemsByPlayer figureItemsByPlayer) { try { using (var entities = new GreatWarriorEntities()) { var figureItem = entities.FigureItemsByPlayers.SingleOrDefault( f => f.Player_Email == figureItemsByPlayer.Player_Email && f.Figure_Name == figureItemsByPlayer.Figure_Name && f.FigureItem_Name == figureItemsByPlayer.FigureItem_Name); if (figureItem == null) { return(Content(HttpStatusCode.NotFound, false)); } entities.FigureItemsByPlayers.Remove(figureItem); entities.SaveChanges(); return(Content(HttpStatusCode.OK, true)); } } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, ex)); } }