Ejemplo n.º 1
0
        public IEnumerable <SpellListItem> GetSpells(int spellbookId)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var svc = new SpellService();

                var query =
                    ctx.Entries
                    .Where(e => e.SpellbookId == spellbookId && GetSpellbookById(spellbookId).UserId == _userId)
                    .Select(e =>
                            new SpellListItem
                {
                    SpellName      = svc.GetSpellById(e.SpellId).SpellName,
                    SpellLevel     = svc.GetSpellById(e.SpellId).SpellLevel,
                    SpellSchool    = svc.GetSpellById(e.SpellId).SpellSchool,
                    CastingTime    = svc.GetSpellById(e.SpellId).CastingTime,
                    SpellRange     = svc.GetSpellById(e.SpellId).SpellRange,
                    VComponents    = svc.GetSpellById(e.SpellId).VComponents,
                    SComponents    = svc.GetSpellById(e.SpellId).SComponents,
                    HasMComponents = svc.GetSpellById(e.SpellId).HasMComponents,
                    Duration       = svc.GetSpellById(e.SpellId).Duration,
                }
                            );

                return(query.ToArray());
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <EntryListItem> GetSpells(int spellbookId)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var query =
                    ctx.Entries
                    .Where(e => e.SpellbookId == spellbookId)
                    .Select(e =>
                            new EntryListItem
                {
                    EntryId = e.EntryId,
                    SpellId = e.SpellId
                })
                    .ToList();

                SpellService spellSvc = new SpellService();

                foreach (var item in query)
                {
                    var spell = spellSvc.GetSpellById(spellId: item.SpellId);

                    item.SpellName      = spell.SpellName;
                    item.SpellLevel     = spell.SpellLevel;
                    item.SpellSchool    = spell.SpellSchool;
                    item.CastingTime    = spell.CastingTime;
                    item.SpellRange     = spell.SpellRange;
                    item.VComponents    = spell.VComponents;
                    item.SComponents    = spell.SComponents;
                    item.HasMComponents = spell.HasMComponents;
                    item.Duration       = spell.Duration;
                }

                return(query);
            }
        }