public IHttpActionResult SetDeckCardPlayable(HerocardDTO card) { var tmp = q.SetDeckPlayable(card.Id, User.Identity.GetUserId()); if (tmp) { return(Content(HttpStatusCode.OK, tmp)); } return(Content(HttpStatusCode.BadRequest, tmp)); }
public IHttpActionResult UpdateHerocard(HerocardDTO card) { var tmp = q.UpdateHerocard(card); if (tmp) { return(Ok(tmp)); } return(BadRequest("Not updated")); }
public IHttpActionResult SellHerocard(HerocardDTO card) { var tmp = q.SellHerocard(card.Id, User.Identity.GetUserId()); var log = new { success = tmp }; if (tmp) { return(Content(HttpStatusCode.OK, log)); } return(Content(HttpStatusCode.BadRequest, log)); }
public IHttpActionResult CreateHerocard(HerocardDTO card) { var tmp = q.CreateHerocard(card); var log = new { sucess = tmp }; if (tmp) { return(Content(HttpStatusCode.OK, log)); } return(Content(HttpStatusCode.BadRequest, log)); }
private Herocard FromDTO(HerocardDTO card) => new Herocard { Name = card.Name, Description = card.Description, Health = card.Health, Attack_Power = card.Attack_Power, Defense_Power = card.Defense_Power, Level_Power = card.Level_Power, Price = card.Price, Poster = card.Poster, Active = card.Active, Visible = card.Visible };
public bool UpdateHerocard(HerocardDTO hero) { bool result; try { var tmp = db.Herocard.Find(hero.Id); db.Entry(tmp).CurrentValues.SetValues(hero); db.SaveChanges(); result = true; } catch (Exception) { result = false; } return(result); }
public bool CreateHerocard(HerocardDTO hero) { bool result; try { if (hero.Name == null) { throw new Exception("Herocard name was null"); } hero.Active = true; hero.Visible = true; db.Herocard.Add(FromDTO(hero)); db.SaveChanges(); result = true; } catch (Exception) { result = false; } return(result); }