private static List <Card> GetWords(bool active) { var activeWords = new List <Card>(); var tbl = new CardRepository(); IEnumerable <dynamic> words = tbl.All(where : "WHERE IsArchived=@0", args: (active == true ? 0 : 1)); foreach (var record in words) { var card = new Card(); card.id = record.CardId; card.correctCount = record.TimesCorrect; card.incorrectCount = record.TimesIncorrect; card.isArchived = record.IsArchived == 1 ? true : false; card.recto = record.Recto; card.verso = record.Verso; activeWords.Add(card); } return(activeWords); }
public ActionResult Index() { var cards = _repo.All(); var vm = new List <Card>(); foreach (dynamic card in cards) { vm.Add(new Card { id = Convert.ToInt32(card.CardId), recto = card.Recto, verso = card.Verso, correctCount = card.TimesCorrect, incorrectCount = card.TimesIncorrect, isArchived = Convert.ToBoolean(card.IsArchived), userId = card.UserId }); } return(Json(vm, JsonRequestBehavior.AllowGet)); }