Ejemplo n.º 1
0
        public IHttpActionResult PutTypeOfCard(int id, TypeOfCard typeOfCard)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != typeOfCard.TypeOfCardID)
            {
                return(BadRequest());
            }

            db.Entry(typeOfCard).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeOfCardExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public CardTypeModel GetCardType(TypeOfCard typeOfCard)
        {
            switch (typeOfCard)
            {
            case TypeOfCard.Adventure:
                return(GetCardTypeModel(AdventureId, AdventureName));

            case TypeOfCard.Character:
                return(GetCardTypeModel(CharacterId, CharacterName));

            case TypeOfCard.Creature:
                return(GetCardTypeModel(CreatureId, CreatureName));

            case TypeOfCard.Item:
                return(GetCardTypeModel(ItemId, ItemName));

            case TypeOfCard.Lesson:
                return(GetCardTypeModel(LessonId, LessonName));

            case TypeOfCard.Location:
                return(GetCardTypeModel(LocationId, LocationName));

            case TypeOfCard.Match:
                return(GetCardTypeModel(MatchId, MatchName));

            case TypeOfCard.Spell:
                return(GetCardTypeModel(SpellId, SpellName));

            default:
                throw new Exception("Card type not recognized.");
            }
        }
Ejemplo n.º 3
0
 public override void Apply(TypeOfCard typeOfCard)
 {
     _typeOfCard = typeOfCard;
     _typeSetter = new CardTypeSetter(_type(this));
     _typeSetter.Initialize(ChangeTracker);
     _typeOfCard.AddModifier(_typeSetter);
 }
Ejemplo n.º 4
0
        public Card(int number, string firstName, string lastName, double bill, int bonusBill, TypeOfCard type)
        {
            this.number = number;
            client      = new Client(firstName, lastName);
            this.bills.Add(bill);
            this.bonusBill = bonusBill;
            this.type      = type;

            AddCardToList();
        }
Ejemplo n.º 5
0
        public IHttpActionResult GetTypeOfCard(int id)
        {
            TypeOfCard typeOfCard = db.TypeOfCards.Find(id);

            if (typeOfCard == null)
            {
                return(NotFound());
            }

            return(Ok(typeOfCard));
        }
Ejemplo n.º 6
0
        public override void Apply(TypeOfCard typeOfCard)
        {
            _typeOfCard = typeOfCard;

            var type = _typeOfCard.Value.Change(subTypes: _landSubtype);

            _cardTypeModifier = new CardTypeSetter(type);
            _cardTypeModifier.Initialize(ChangeTracker);

            _typeOfCard.AddModifier(_cardTypeModifier);
        }
Ejemplo n.º 7
0
        public IHttpActionResult PostTypeOfCard(TypeOfCard typeOfCard)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TypeOfCards.Add(typeOfCard);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = typeOfCard.TypeOfCardID }, typeOfCard));
        }
Ejemplo n.º 8
0
        public IHttpActionResult DeleteTypeOfCard(int id)
        {
            TypeOfCard typeOfCard = db.TypeOfCards.Find(id);

            if (typeOfCard == null)
            {
                return(NotFound());
            }

            db.TypeOfCards.Remove(typeOfCard);
            db.SaveChanges();

            return(Ok(typeOfCard));
        }
Ejemplo n.º 9
0
 public Card(TypeOfCard typeOfCard, CardValue cardValue)
 {
     TypeOfCard = typeOfCard;
     NameOfCard = cardValue;
 }