public static Column Convert(Deck.Column column, Dictionary<string, Card> cards) { return new Column { Cards = column.CardIds.Select(c => cards[c]).ToList(), }; }
public static DeckViewModel Convert(Deck deck, Dictionary<string, Card> cards) { return new DeckViewModel { Id = deck.Id, Name = deck.Name, Columns = deck.Columns.Select(c => Column.Convert(c, cards)).ToList(), }; }
public ActionResult Create(Deck deck) { if (!ModelState.IsValid) { throw new Exception("F**k!"); } using (var session = MvcApplication.DocumentStore.OpenSession()) { session.Store(deck); session.SaveChanges(); return RedirectToAction("edit", new { id = deck.Id, slug = deck.Name.Slugify() }); } }