Esempio n. 1
0
        public IActionResult Index(SetViewModel model)
        {
            try
            {
                var setCode = model.Set.code;
                var cards   = new List <Card>();

                if (setCode == "KLD" || setCode == "kld")
                {
                    using (StreamReader r = System.IO.File.OpenText(@"wwwroot/js/KLD.json"))
                    {
                        string json    = r.ReadToEnd();
                        var    cardDTO = JsonConvert.DeserializeObject <CardDTO>(json);
                        cards = cardDTO.Cards;
                    }
                }
                else
                {
                    cards = MTGAPI.GetCardsBySetCode(setCode);
                }

                var rarityFilter = model.RarityFilter;
                var colorFilter  = model.ColorFilter;

                var rarityPredicate = GetRarityFilter(rarityFilter);
                var colorPredicate  = GetColorFilter(colorFilter);

                cards = cards
                        .Where(c => !c.type.Contains("Basic Land"))
                        .Where(rarityPredicate)
                        .Where(colorPredicate)
                        .OrderBy(c => c.number, new CardComparer())
                        .ToList();

                var userGrades = new CardListViewModel();
                foreach (var card in cards)
                {
                    var cvm = new CardViewModel()
                    {
                        Card  = card,
                        Grade = new Grade()
                        {
                            CardName     = card.name,
                            MultiverseID = card.multiverseid ?? -1,
                            Value        = GradeEnum.None
                        }
                    };

                    userGrades.CardViewModels.Add(cvm);
                }

                return(PartialView("EditorTemplates/CardListViewModel", userGrades));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", model.Set.code));
            }
        }
Esempio n. 2
0
        public ActionResult Sale()
        {
            string            whr  = "UserId is not null";
            FINCardBLL        bll  = new FINCardBLL();
            var               list = bll.Query(whr, "statusday", 1, out int i, false, 10);
            CardListViewModel mdl  = new CardListViewModel()
            {
                Cards     = list,
                Pager     = Common.Utility.HtmlPager(10, 1, i, 5),
                ttlRecord = i
            };

            return(PartialView(mdl));
        }
Esempio n. 3
0
        /// <summary>
        /// card list by config.
        /// </summary>
        /// <param name="id">config id</param>
        /// <param name="pg"></param>
        /// <returns></returns>
        public ActionResult CardList(string id, int pg = 1)
        {
            int    i;
            string whr       = string.Format("CardConfigId='{0}'", id);
            var    viewModel = new CardListViewModel()
            {
                Cards       = _financeSv.QueryCards(whr, null, pg, out i, 10),
                Pager       = Common.Utility.HtmlPager(10, pg, i, 5),
                ttlRecord   = i,
                StatusCount = _financeSv.CountStatus(id)
            };

            return(PartialView(viewModel));
        }
Esempio n. 4
0
        /// <summary>
        /// list card list by card status--partial page.
        /// </summary>
        /// <param name="status"></param>
        /// <param name="pg"></param>
        /// <returns></returns>
        public ActionResult statusCards(string statusStr, string configId, int pg = 1)
        {
            int i;

            if (string.IsNullOrWhiteSpace(statusStr))
            {
                statusStr = "NeverUsed";
            }
            AppConfigs.SingleCardStatus status = (AppConfigs.SingleCardStatus)Enum.Parse(typeof(AppConfigs.SingleCardStatus), statusStr, false);
            var mdl     = _financeSv.ListStatusCards(status, configId, pg, out i);
            var cardlst = new CardListViewModel()
            {
                Cards       = mdl,
                Pager       = Common.Utility.HtmlPager(10, pg, i, 5),
                ttlRecord   = i,
                StatusCount = _financeSv.CountStatus(configId)
            };

            return(PartialView(cardlst));
        }
        private void listbox_MouseMove(object sender, MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.LeftButton == MouseButtonState.Pressed && ((CardListViewModel)DataContext).SelectedCard != null)
            {
                if (DataContext is CardListViewModel)
                {
                    CardListViewModel cardListVM = DataContext as CardListViewModel;
                    ReadCardList      cardList   = cardListVM.CardList;
                    ReadCard          card       = cardListVM.SelectedCard;

                    MoveCard moveCard = new MoveCard()
                    {
                        CardId = card.CardId, OldListId = cardList.ListId, NewListId = cardList.ListId
                    };

                    DataObject data = new DataObject();
                    data.SetData(typeof(MoveCard), moveCard);

                    DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
                    cardListVM.OnMoveCardDrag(card.CardId);
                }
            }
        }
Esempio n. 6
0
        public IActionResult Index(string id = "")
        {
            var set   = new Set();
            var cards = new List <Card>();

            if (id == "KLD" || id == "kld")
            {
                set = new Set()
                {
                    name        = "Kaladesh",
                    code        = "KLD",
                    releaseDate = "2016-09-30"
                };

                using (StreamReader r = System.IO.File.OpenText(@"wwwroot/js/KLD.json"))
                {
                    string json    = r.ReadToEnd();
                    var    cardDTO = JsonConvert.DeserializeObject <CardDTO>(json);
                    cards = cardDTO.Cards;
                }
            }
            else
            {
                set   = MTGAPI.GetSetBySetCode(id);
                cards = MTGAPI.GetCardsBySetCode(id);
            }

            var lrSetReviewQuery = db.SetReviews
                                   .Where(sr => sr.SetCode.Equals(id, StringComparison.OrdinalIgnoreCase))
                                   .FirstOrDefault();

            var lrSetReview = (lrSetReviewQuery == null) ? new List <Grade>() : lrSetReviewQuery.Grades;

            var rarityFilter = new Dictionary <string, bool>()
            {
                { "Common", false },
                { "Uncommon", false },
                { "Rare", false },
                { "Mythic Rare", false },
            };

            var colorFilter = new Dictionary <string, bool>()
            {
                { "White", false },
                { "Blue", false },
                { "Black", false },
                { "Red", false },
                { "Green", false },
                { "Colorless", false }
            };

            cards = cards
                    .Where(c => !c.type.Contains("Basic Land"))
                    .OrderBy(c => c.number, new CardComparer())
                    .ToList();

            var userGrades = new CardListViewModel();

            foreach (var card in cards)
            {
                var cvm = new CardViewModel()
                {
                    Card  = card,
                    Grade = new Grade()
                    {
                        CardName     = card.name,
                        MultiverseID = card.multiverseid ?? -1,
                        Value        = GradeEnum.None
                    }
                };

                userGrades.CardViewModels.Add(cvm);
            }

            return(View(new SetViewModel()
            {
                RarityFilter = rarityFilter,
                ColorFilter = colorFilter,
                Set = set,
                Cards = cards,
                UserGrades = userGrades
            }));
        }
        internal void LoadState()
        {
            if (ViewModelBase.IsInDesignModeStatic)
                return;

            string data;

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (store.FileExists(STR_CardListViewModel))
                {
                    using (var stream = store.OpenFile(STR_CardListViewModel, FileMode.Open))
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            data = reader.ReadToEnd();
                        }
                    }
                    _gameCardList = JsonConvert.DeserializeObject<CardListViewModel>(data);
                }
                if (store.FileExists(STR_SettingsViewModel))
                {
                    using (var stream = store.OpenFile(STR_SettingsViewModel, FileMode.Open))
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            data = reader.ReadToEnd();
                        }
                    }
                    _settingsViewModel = JsonConvert.DeserializeObject<SettingsViewModel>(data);
                }
            }
        }
 /// <summary>
 /// Provides a deterministic way to create the CardListViewModel property.
 /// </summary>
 public static void CreateCardListViewModel()
 {
     if (_gameCardList == null)
     {
         _gameCardList = new CardListViewModel();
     }
 }
 /// <summary>
 /// Provides a deterministic way to delete the CardListViewModel property.
 /// </summary>
 public static void ClearCardListViewModel()
 {
     _gameCardList.Cleanup();
     _gameCardList = null;
 }