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));
        }
예제 #2
0
        public IHttpActionResult UpdateHerocard(HerocardDTO card)
        {
            var tmp = q.UpdateHerocard(card);

            if (tmp)
            {
                return(Ok(tmp));
            }
            return(BadRequest("Not updated"));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }