Ejemplo n.º 1
0
        public void PopulateCategoriesDropDownList(Lucaci_Ioana_ProiectFinalContext _context, object selectedCategories = null)
        {
            var categoriesQuery = _context.Category
                                  .OrderBy(c => c.Name)
                                  .Select(c => new
            {
                Text  = c.Name,
                Value = c.ID
            });

            CategoryNames = new SelectList(categoriesQuery.AsNoTracking(), "Value", "Text", selectedCategories);
        }
Ejemplo n.º 2
0
        public void PopulateAuthorsDropDownList(Lucaci_Ioana_ProiectFinalContext _context, object selectedAuthor = null)
        {
            var authorsQuery = _context.Author
                               .OrderBy(a => a.LastName)
                               .Select(a => new
            {
                Text  = a.FirstName + " '" + a.Nickname + "' " + a.LastName,
                Value = a.ID
            });

            AuthorNames = new SelectList(authorsQuery.AsNoTracking(), "Value", "Text", selectedAuthor);
        }