Exemple #1
0
 public Book(string title, Editions edition, Author author, decimal price, int copies, AgeRestrictions ageRestriction, DateTime? releaseDate = null, string description = null)
 {
     this.Title = title;
     this.Description = description;
     this.Edition = edition;
     this.author = author;
     this.Price = price;
     this.Copies = copies;
     this.ReleaseDate = releaseDate;
     this.categories = new HashSet<Category>();
     this.AgeRestriction = ageRestriction;
     this.relatedBooks = new HashSet<Book>();
 }
        private void RefreshDisplayedData(InputMode modifyData)
        {
            UpdateCurrentCollectionDetailAndTranslate();

            //None one the key changed, nothing to recompute
            if (modifyData == InputMode.None)
            {
                return;
            }

            //Change one of the key but no the reference one
            if (InputMode != modifyData)
            {
                Languages.Clear();
                IEdition editionSelected  = EditionSelected;
                ICard    cardNameSelected = _cardSelected;
                if (editionSelected == null || cardNameSelected == null)
                {
                    return;
                }

                ICardAllDbInfo cardAllDbInfo = _allCardInfos.First(cadi => cadi.Edition == editionSelected && cadi.Card == cardNameSelected);
                if (cardAllDbInfo == null)
                {
                    return;
                }

                foreach (ILanguage language in _magicDatabase.GetLanguages(cardAllDbInfo.IdGatherer))
                {
                    Languages.Add(language);
                }

                if (Languages.Count > 0)
                {
                    if (_inputLanguage != null && Languages.Contains(_inputLanguage))
                    {
                        LanguageSelected = _inputLanguage;
                    }
                    else
                    {
                        LanguageSelected = Languages[0];
                    }
                }
            }
            else
            {
                //Change the reference
                switch (InputMode)
                {
                case InputMode.ByEdition:

                    IEdition editionSelected = EditionSelected;
                    Cards.Clear();
                    Languages.Clear();
                    if (editionSelected == null)
                    {
                        return;
                    }

                    List <string> sorted = new List <string>();
                    //Could not call directly GetAllCardsOrderByTranslation because the key must be the same as in all card even if there is no duplicate traduction in the subset
                    foreach (KeyValuePair <string, ICard> kv in _allCardInfos.Where(cadi => cadi.Edition == editionSelected).GetAllCardWithTranslation(_inputLanguage))
                    {
                        //Normal case
                        if (_allCardSorted.ContainsKey(kv.Key))
                        {
                            sorted.Add(kv.Key);
                        }
                        else
                        {
                            //Key was changed because of duplicate traduction, we need to look for the card
                            sorted.Add(_allCardSorted.First(acsKv => kv.Value == acsKv.Value).Key);
                        }
                    }
                    sorted.Sort();
                    Cards.AddRange(sorted);
                    break;

                case InputMode.ByCard:

                    ICard cardNameSelected = _cardSelected;
                    Editions.Clear();
                    Languages.Clear();
                    if (cardNameSelected == null)
                    {
                        return;
                    }

                    foreach (IEdition edition in _allCardInfos.GetAllEditionIncludingCardOrdered(cardNameSelected))
                    {
                        Editions.Add(edition);
                    }

                    if (Editions.Count > 0)
                    {
                        EditionSelected = Editions[0];
                    }

                    break;
                }
            }
        }
 public void Delete(Editions editionToDelete)
 {
     editionRepository.Delete(editionToDelete);
 }
 public Editions UpdateEdition(Editions editionToUpdate)
 {
     return(editionRepository.Update(editionToUpdate));
 }
Exemple #5
0
        public static void LoadFromDatabase()
        {
            // load abilities
            List <Ability> abilities = new List <Ability>();

            using (DAL dal = DAL.FromConfiguration("sqlite")) {
                IDbCommand cmd = dal.CreateCommand();
                cmd.CommandText = "SELECT * FROM Abilities";

                dal.OpenConnection();

                using (IDataReader reader = dal.ExecuteQueryForDataReader(cmd)) {
                    while (reader.Read())
                    {
                        Ability item = new Ability();

                        long id = reader.GetSafeValue <long>("Id");
                        item.Id = Convert.ToInt32(id);

                        long cardId = reader.GetSafeValue <long>("CardId");
                        item.CardId = Convert.ToInt32(cardId);

                        item.Name           = reader.GetSafeValue <string>("Name");
                        item.Description    = reader.GetSafeValue <string>("Description");
                        item.ActivationCost = reader.GetSafeValue <string>("ActivationCost");
                        item.TapToActivate  = reader.GetSafeValue <bool>("TapToActivate");

                        abilities.Add(item);
                    }
                }
            }

            using (DAL dal = DAL.FromConfiguration("sqlite")) {
                IDbCommand cmd = dal.CreateCommand();
                cmd.CommandText = @"
					SELECT c.Id, c.Name, CastingCost, Type
						,Color, Flavour, Abilities, Rarity, Artist
						,e.Name AS EditionName, e.Id AS EditionId, Shortname
					FROM Cards AS c
					INNER JOIN Cards2Editions AS c2e ON c.Id = c2e.CardId
					INNER JOIN Editions AS e ON c2e.EditionId = e.Id
				"                ;

                dal.OpenConnection();

                using (IDataReader reader = dal.ExecuteQueryForDataReader(cmd)) {
                    while (reader.Read())
                    {
                        Card card = new Card();

                        long cardId = reader.GetSafeValue <long>("Id");
                        card.Id = Convert.ToInt32(cardId);

                        card.Name        = reader.GetSafeValue <string>("Name");
                        card.CastingCost = reader.GetSafeValue <string>("CastingCost");
                        card.Type        = reader.GetSafeValue <string>("Type");

                        card.Color = new List <CardColor>();
                        //card.Color = "";
                        string colors = reader.GetSafeValue <string>("Color");
                        foreach (char color in colors)
                        {
                            card.Color.Add(new CardColor()
                            {
                                Symbol = color.ToString().ToEnum <ColorSymbol>()
                            });
                            //card.Color += color;
                        }

                        card.Flavour         = reader.GetSafeValue <string>("Flavour");
                        card.Rarity          = reader.GetSafeValue <string>("Rarity").ToEnum <Rarity>();
                        card.Artist          = reader.GetSafeValue <string>("Artist");
                        card.PowerThoughness = reader.GetSafeValue <string>("PT");
                        card.Text            = reader.GetSafeValue <string>("Text");

                        // edition
                        Edition edition   = new Edition();
                        long    editionId = reader.GetSafeValue <long>("EditionId");
                        edition.Id        = Convert.ToInt32(editionId);
                        edition.Name      = reader.GetSafeValue <string>("EditionName");
                        edition.Shortname = reader.GetSafeValue <string>("Shortname");

                        var edi =
                            from item in Editions
                            where item.Id == edition.Id &&
                            item.Name == edition.Name &&
                            item.Shortname == edition.Shortname
                            select item;

                        if (edi.Count() == 0
                            )
                        {
                            edition.Cards.Add(card);

                            Editions.Add(edition);
                        }
                        else
                        {
                            ((Edition)edi).Cards.Add(card);
                        }

                        var ediPics =
                            from item in card.EditionPictures
                            where item.Key.Id == edition.Id &&
                            item.Key.Name == edition.Name &&
                            item.Key.Shortname == edition.Shortname
                            select item;

                        if (ediPics.Count() == 0)
                        {
                            card.EditionPictures.Add(edition, null);
                        }
                        else
                        {
                            card.EditionPictures[edition] = null;
                        }

                        //// load abilities
                        //var abi = from item in abilities
                        //          where item.CardId == card.Id
                        //          select item;

                        //foreach(Ability item in abi) {
                        //    card.Abilities.Add(item);
                        //}

                        Cards.Add(card);
                    }
                }
            }

            IsInitialized = true;
        }
 public void Delete(Editions editionToDelete)
 {
     editionToDelete = conferenceContext.Editions.Find(editionToDelete.Id);
     conferenceContext.Editions.Remove(editionToDelete);
 }
Exemple #7
0
        public void Delete(Editions editions)
        {
            var del = conferenceContext.Editions.Remove(editions);

            conferenceContext.SaveChanges();
        }
        //Methods
        public Edition LatestEdition()
        {
            var latestEdition = Editions.OrderByDescending(x => x.Version.ToString()).FirstOrDefault();

            return(latestEdition);
        }
        public int CalculatedAwardedXp()
        {
            var calculatedXp = Editions.Sum(x => x.CalculatedAwardedXp());

            return(calculatedXp);
        }
 public void DeleteEdition(Editions editions)
 {
     editionRepository.Delete(editions);
 }
Exemple #11
0
        public Editions Update(Editions editions)
        {
            var update = editionRepository.Update(editions);

            return(update);
        }
Exemple #12
0
 public async Task <IReadOnlyList <Edition> > GetAll()
 {
     return(await Editions.Where(v => v.Id != 1).ToListAsync());
 }