Shady nagy/net6 (#614)
* udated to .net6 * used the .net6 version RC2 * added editconfig. * App core new Scoped Namespaces style. * BlazorAdmin new Scoped Namespaces style. * Blazor Shared new Scoped Namespaces style. * Infra new Scoped Namespaces style. * public api new Scoped Namespaces style. * web new Scoped Namespaces style. * FunctionalTests new Scoped Namespaces style. * Integrational tests new Scoped Namespaces style. * unit tests new Scoped Namespaces style. * update github action. * update github action. * change the global.
This commit is contained in:
@@ -1,97 +1,96 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Specifications;
|
||||
using Microsoft.eShopWeb.Web.Interfaces;
|
||||
using Microsoft.eShopWeb.Web.Pages.Basket;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.Web.Services
|
||||
namespace Microsoft.eShopWeb.Web.Services;
|
||||
|
||||
public class BasketViewModelService : IBasketViewModelService
|
||||
{
|
||||
public class BasketViewModelService : IBasketViewModelService
|
||||
private readonly IRepository<Basket> _basketRepository;
|
||||
private readonly IUriComposer _uriComposer;
|
||||
private readonly IBasketQueryService _basketQueryService;
|
||||
private readonly IRepository<CatalogItem> _itemRepository;
|
||||
|
||||
public BasketViewModelService(IRepository<Basket> basketRepository,
|
||||
IRepository<CatalogItem> itemRepository,
|
||||
IUriComposer uriComposer,
|
||||
IBasketQueryService basketQueryService)
|
||||
{
|
||||
private readonly IRepository<Basket> _basketRepository;
|
||||
private readonly IUriComposer _uriComposer;
|
||||
private readonly IBasketQueryService _basketQueryService;
|
||||
private readonly IRepository<CatalogItem> _itemRepository;
|
||||
_basketRepository = basketRepository;
|
||||
_uriComposer = uriComposer;
|
||||
_basketQueryService = basketQueryService;
|
||||
_itemRepository = itemRepository;
|
||||
}
|
||||
|
||||
public BasketViewModelService(IRepository<Basket> basketRepository,
|
||||
IRepository<CatalogItem> itemRepository,
|
||||
IUriComposer uriComposer,
|
||||
IBasketQueryService basketQueryService)
|
||||
public async Task<BasketViewModel> GetOrCreateBasketForUser(string userName)
|
||||
{
|
||||
var basketSpec = new BasketWithItemsSpecification(userName);
|
||||
var basket = (await _basketRepository.GetBySpecAsync(basketSpec));
|
||||
|
||||
if (basket == null)
|
||||
{
|
||||
_basketRepository = basketRepository;
|
||||
_uriComposer = uriComposer;
|
||||
_basketQueryService = basketQueryService;
|
||||
_itemRepository = itemRepository;
|
||||
return await CreateBasketForUser(userName);
|
||||
}
|
||||
var viewModel = await Map(basket);
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public async Task<BasketViewModel> GetOrCreateBasketForUser(string userName)
|
||||
private async Task<BasketViewModel> CreateBasketForUser(string userId)
|
||||
{
|
||||
var basket = new Basket(userId);
|
||||
await _basketRepository.AddAsync(basket);
|
||||
|
||||
return new BasketViewModel()
|
||||
{
|
||||
var basketSpec = new BasketWithItemsSpecification(userName);
|
||||
var basket = (await _basketRepository.GetBySpecAsync(basketSpec));
|
||||
BuyerId = basket.BuyerId,
|
||||
Id = basket.Id,
|
||||
};
|
||||
}
|
||||
|
||||
if (basket == null)
|
||||
{
|
||||
return await CreateBasketForUser(userName);
|
||||
}
|
||||
var viewModel = await Map(basket);
|
||||
return viewModel;
|
||||
}
|
||||
private async Task<List<BasketItemViewModel>> GetBasketItems(IReadOnlyCollection<BasketItem> basketItems)
|
||||
{
|
||||
var catalogItemsSpecification = new CatalogItemsSpecification(basketItems.Select(b => b.CatalogItemId).ToArray());
|
||||
var catalogItems = await _itemRepository.ListAsync(catalogItemsSpecification);
|
||||
|
||||
private async Task<BasketViewModel> CreateBasketForUser(string userId)
|
||||
var items = basketItems.Select(basketItem =>
|
||||
{
|
||||
var basket = new Basket(userId);
|
||||
await _basketRepository.AddAsync(basket);
|
||||
var catalogItem = catalogItems.First(c => c.Id == basketItem.CatalogItemId);
|
||||
|
||||
return new BasketViewModel()
|
||||
var basketItemViewModel = new BasketItemViewModel
|
||||
{
|
||||
BuyerId = basket.BuyerId,
|
||||
Id = basket.Id,
|
||||
Id = basketItem.Id,
|
||||
UnitPrice = basketItem.UnitPrice,
|
||||
Quantity = basketItem.Quantity,
|
||||
CatalogItemId = basketItem.CatalogItemId,
|
||||
PictureUrl = _uriComposer.ComposePicUri(catalogItem.PictureUri),
|
||||
ProductName = catalogItem.Name
|
||||
};
|
||||
}
|
||||
return basketItemViewModel;
|
||||
}).ToList();
|
||||
|
||||
private async Task<List<BasketItemViewModel>> GetBasketItems(IReadOnlyCollection<BasketItem> basketItems)
|
||||
return items;
|
||||
}
|
||||
|
||||
public async Task<BasketViewModel> Map(Basket basket)
|
||||
{
|
||||
return new BasketViewModel()
|
||||
{
|
||||
var catalogItemsSpecification = new CatalogItemsSpecification(basketItems.Select(b => b.CatalogItemId).ToArray());
|
||||
var catalogItems = await _itemRepository.ListAsync(catalogItemsSpecification);
|
||||
BuyerId = basket.BuyerId,
|
||||
Id = basket.Id,
|
||||
Items = await GetBasketItems(basket.Items)
|
||||
};
|
||||
}
|
||||
|
||||
var items = basketItems.Select(basketItem =>
|
||||
{
|
||||
var catalogItem = catalogItems.First(c => c.Id == basketItem.CatalogItemId);
|
||||
public async Task<int> CountTotalBasketItems(string username)
|
||||
{
|
||||
var counter = await _basketQueryService.CountTotalBasketItems(username);
|
||||
|
||||
var basketItemViewModel = new BasketItemViewModel
|
||||
{
|
||||
Id = basketItem.Id,
|
||||
UnitPrice = basketItem.UnitPrice,
|
||||
Quantity = basketItem.Quantity,
|
||||
CatalogItemId = basketItem.CatalogItemId,
|
||||
PictureUrl = _uriComposer.ComposePicUri(catalogItem.PictureUri),
|
||||
ProductName = catalogItem.Name
|
||||
};
|
||||
return basketItemViewModel;
|
||||
}).ToList();
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public async Task<BasketViewModel> Map(Basket basket)
|
||||
{
|
||||
return new BasketViewModel()
|
||||
{
|
||||
BuyerId = basket.BuyerId,
|
||||
Id = basket.Id,
|
||||
Items = await GetBasketItems(basket.Items)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<int> CountTotalBasketItems(string username)
|
||||
{
|
||||
var counter = await _basketQueryService.CountTotalBasketItems(username);
|
||||
|
||||
return counter;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.eShopWeb.Web.Extensions;
|
||||
using Microsoft.eShopWeb.Web.ViewModels;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.Web.Services
|
||||
namespace Microsoft.eShopWeb.Web.Services;
|
||||
|
||||
public class CachedCatalogViewModelService : ICatalogViewModelService
|
||||
{
|
||||
public class CachedCatalogViewModelService : ICatalogViewModelService
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly CatalogViewModelService _catalogViewModelService;
|
||||
|
||||
public CachedCatalogViewModelService(IMemoryCache cache,
|
||||
CatalogViewModelService catalogViewModelService)
|
||||
{
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly CatalogViewModelService _catalogViewModelService;
|
||||
_cache = cache;
|
||||
_catalogViewModelService = catalogViewModelService;
|
||||
}
|
||||
|
||||
public CachedCatalogViewModelService(IMemoryCache cache,
|
||||
CatalogViewModelService catalogViewModelService)
|
||||
public async Task<IEnumerable<SelectListItem>> GetBrands()
|
||||
{
|
||||
return await _cache.GetOrCreateAsync(CacheHelpers.GenerateBrandsCacheKey(), async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
|
||||
return await _catalogViewModelService.GetBrands();
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandId, int? typeId)
|
||||
{
|
||||
var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageIndex, Constants.ITEMS_PER_PAGE, brandId, typeId);
|
||||
|
||||
return await _cache.GetOrCreateAsync(cacheKey, async entry =>
|
||||
{
|
||||
_cache = cache;
|
||||
_catalogViewModelService = catalogViewModelService;
|
||||
}
|
||||
entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
|
||||
return await _catalogViewModelService.GetCatalogItems(pageIndex, itemsPage, brandId, typeId);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SelectListItem>> GetBrands()
|
||||
public async Task<IEnumerable<SelectListItem>> GetTypes()
|
||||
{
|
||||
return await _cache.GetOrCreateAsync(CacheHelpers.GenerateTypesCacheKey(), async entry =>
|
||||
{
|
||||
return await _cache.GetOrCreateAsync(CacheHelpers.GenerateBrandsCacheKey(), async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
|
||||
return await _catalogViewModelService.GetBrands();
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandId, int? typeId)
|
||||
{
|
||||
var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageIndex, Constants.ITEMS_PER_PAGE, brandId, typeId);
|
||||
|
||||
return await _cache.GetOrCreateAsync(cacheKey, async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
|
||||
return await _catalogViewModelService.GetCatalogItems(pageIndex, itemsPage, brandId, typeId);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SelectListItem>> GetTypes()
|
||||
{
|
||||
return await _cache.GetOrCreateAsync(CacheHelpers.GenerateTypesCacheKey(), async entry =>
|
||||
{
|
||||
entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
|
||||
return await _catalogViewModelService.GetTypes();
|
||||
});
|
||||
}
|
||||
entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
|
||||
return await _catalogViewModelService.GetTypes();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
||||
using Microsoft.eShopWeb.Web.Interfaces;
|
||||
using Microsoft.eShopWeb.Web.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.Web.Services
|
||||
namespace Microsoft.eShopWeb.Web.Services;
|
||||
|
||||
public class CatalogItemViewModelService : ICatalogItemViewModelService
|
||||
{
|
||||
public class CatalogItemViewModelService : ICatalogItemViewModelService
|
||||
private readonly IRepository<CatalogItem> _catalogItemRepository;
|
||||
|
||||
public CatalogItemViewModelService(IRepository<CatalogItem> catalogItemRepository)
|
||||
{
|
||||
private readonly IRepository<CatalogItem> _catalogItemRepository;
|
||||
_catalogItemRepository = catalogItemRepository;
|
||||
}
|
||||
|
||||
public CatalogItemViewModelService(IRepository<CatalogItem> catalogItemRepository)
|
||||
{
|
||||
_catalogItemRepository = catalogItemRepository;
|
||||
}
|
||||
|
||||
public async Task UpdateCatalogItem(CatalogItemViewModel viewModel)
|
||||
{
|
||||
var existingCatalogItem = await _catalogItemRepository.GetByIdAsync(viewModel.Id);
|
||||
existingCatalogItem.UpdateDetails(viewModel.Name, existingCatalogItem.Description, viewModel.Price);
|
||||
await _catalogItemRepository.UpdateAsync(existingCatalogItem);
|
||||
}
|
||||
public async Task UpdateCatalogItem(CatalogItemViewModel viewModel)
|
||||
{
|
||||
var existingCatalogItem = await _catalogItemRepository.GetByIdAsync(viewModel.Id);
|
||||
existingCatalogItem.UpdateDetails(viewModel.Name, existingCatalogItem.Description, viewModel.Price);
|
||||
await _catalogItemRepository.UpdateAsync(existingCatalogItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,112 +1,111 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Specifications;
|
||||
using Microsoft.eShopWeb.Web.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.Web.Services
|
||||
namespace Microsoft.eShopWeb.Web.Services;
|
||||
|
||||
/// <summary>
|
||||
/// This is a UI-specific service so belongs in UI project. It does not contain any business logic and works
|
||||
/// with UI-specific types (view models and SelectListItem types).
|
||||
/// </summary>
|
||||
public class CatalogViewModelService : ICatalogViewModelService
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a UI-specific service so belongs in UI project. It does not contain any business logic and works
|
||||
/// with UI-specific types (view models and SelectListItem types).
|
||||
/// </summary>
|
||||
public class CatalogViewModelService : ICatalogViewModelService
|
||||
private readonly ILogger<CatalogViewModelService> _logger;
|
||||
private readonly IRepository<CatalogItem> _itemRepository;
|
||||
private readonly IRepository<CatalogBrand> _brandRepository;
|
||||
private readonly IRepository<CatalogType> _typeRepository;
|
||||
private readonly IUriComposer _uriComposer;
|
||||
|
||||
public CatalogViewModelService(
|
||||
ILoggerFactory loggerFactory,
|
||||
IRepository<CatalogItem> itemRepository,
|
||||
IRepository<CatalogBrand> brandRepository,
|
||||
IRepository<CatalogType> typeRepository,
|
||||
IUriComposer uriComposer)
|
||||
{
|
||||
private readonly ILogger<CatalogViewModelService> _logger;
|
||||
private readonly IRepository<CatalogItem> _itemRepository;
|
||||
private readonly IRepository<CatalogBrand> _brandRepository;
|
||||
private readonly IRepository<CatalogType> _typeRepository;
|
||||
private readonly IUriComposer _uriComposer;
|
||||
_logger = loggerFactory.CreateLogger<CatalogViewModelService>();
|
||||
_itemRepository = itemRepository;
|
||||
_brandRepository = brandRepository;
|
||||
_typeRepository = typeRepository;
|
||||
_uriComposer = uriComposer;
|
||||
}
|
||||
|
||||
public CatalogViewModelService(
|
||||
ILoggerFactory loggerFactory,
|
||||
IRepository<CatalogItem> itemRepository,
|
||||
IRepository<CatalogBrand> brandRepository,
|
||||
IRepository<CatalogType> typeRepository,
|
||||
IUriComposer uriComposer)
|
||||
public async Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandId, int? typeId)
|
||||
{
|
||||
_logger.LogInformation("GetCatalogItems called.");
|
||||
|
||||
var filterSpecification = new CatalogFilterSpecification(brandId, typeId);
|
||||
var filterPaginatedSpecification =
|
||||
new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId);
|
||||
|
||||
// the implementation below using ForEach and Count. We need a List.
|
||||
var itemsOnPage = await _itemRepository.ListAsync(filterPaginatedSpecification);
|
||||
var totalItems = await _itemRepository.CountAsync(filterSpecification);
|
||||
|
||||
var vm = new CatalogIndexViewModel()
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<CatalogViewModelService>();
|
||||
_itemRepository = itemRepository;
|
||||
_brandRepository = brandRepository;
|
||||
_typeRepository = typeRepository;
|
||||
_uriComposer = uriComposer;
|
||||
}
|
||||
|
||||
public async Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandId, int? typeId)
|
||||
{
|
||||
_logger.LogInformation("GetCatalogItems called.");
|
||||
|
||||
var filterSpecification = new CatalogFilterSpecification(brandId, typeId);
|
||||
var filterPaginatedSpecification =
|
||||
new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId);
|
||||
|
||||
// the implementation below using ForEach and Count. We need a List.
|
||||
var itemsOnPage = await _itemRepository.ListAsync(filterPaginatedSpecification);
|
||||
var totalItems = await _itemRepository.CountAsync(filterSpecification);
|
||||
|
||||
var vm = new CatalogIndexViewModel()
|
||||
CatalogItems = itemsOnPage.Select(i => new CatalogItemViewModel()
|
||||
{
|
||||
CatalogItems = itemsOnPage.Select(i => new CatalogItemViewModel()
|
||||
{
|
||||
Id = i.Id,
|
||||
Name = i.Name,
|
||||
PictureUri = _uriComposer.ComposePicUri(i.PictureUri),
|
||||
Price = i.Price
|
||||
}).ToList(),
|
||||
Brands = (await GetBrands()).ToList(),
|
||||
Types = (await GetTypes()).ToList(),
|
||||
BrandFilterApplied = brandId ?? 0,
|
||||
TypesFilterApplied = typeId ?? 0,
|
||||
PaginationInfo = new PaginationInfoViewModel()
|
||||
{
|
||||
ActualPage = pageIndex,
|
||||
ItemsPerPage = itemsOnPage.Count,
|
||||
TotalItems = totalItems,
|
||||
TotalPages = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString())
|
||||
}
|
||||
};
|
||||
Id = i.Id,
|
||||
Name = i.Name,
|
||||
PictureUri = _uriComposer.ComposePicUri(i.PictureUri),
|
||||
Price = i.Price
|
||||
}).ToList(),
|
||||
Brands = (await GetBrands()).ToList(),
|
||||
Types = (await GetTypes()).ToList(),
|
||||
BrandFilterApplied = brandId ?? 0,
|
||||
TypesFilterApplied = typeId ?? 0,
|
||||
PaginationInfo = new PaginationInfoViewModel()
|
||||
{
|
||||
ActualPage = pageIndex,
|
||||
ItemsPerPage = itemsOnPage.Count,
|
||||
TotalItems = totalItems,
|
||||
TotalPages = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString())
|
||||
}
|
||||
};
|
||||
|
||||
vm.PaginationInfo.Next = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "is-disabled" : "";
|
||||
vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "is-disabled" : "";
|
||||
vm.PaginationInfo.Next = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "is-disabled" : "";
|
||||
vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "is-disabled" : "";
|
||||
|
||||
return vm;
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SelectListItem>> GetBrands()
|
||||
{
|
||||
_logger.LogInformation("GetBrands called.");
|
||||
var brands = await _brandRepository.ListAsync();
|
||||
public async Task<IEnumerable<SelectListItem>> GetBrands()
|
||||
{
|
||||
_logger.LogInformation("GetBrands called.");
|
||||
var brands = await _brandRepository.ListAsync();
|
||||
|
||||
var items = brands
|
||||
.Select(brand => new SelectListItem() { Value = brand.Id.ToString(), Text = brand.Brand })
|
||||
.OrderBy(b => b.Text)
|
||||
.ToList();
|
||||
var items = brands
|
||||
.Select(brand => new SelectListItem() { Value = brand.Id.ToString(), Text = brand.Brand })
|
||||
.OrderBy(b => b.Text)
|
||||
.ToList();
|
||||
|
||||
var allItem = new SelectListItem() { Value = null, Text = "All", Selected = true };
|
||||
items.Insert(0, allItem);
|
||||
var allItem = new SelectListItem() { Value = null, Text = "All", Selected = true };
|
||||
items.Insert(0, allItem);
|
||||
|
||||
return items;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SelectListItem>> GetTypes()
|
||||
{
|
||||
_logger.LogInformation("GetTypes called.");
|
||||
var types = await _typeRepository.ListAsync();
|
||||
public async Task<IEnumerable<SelectListItem>> GetTypes()
|
||||
{
|
||||
_logger.LogInformation("GetTypes called.");
|
||||
var types = await _typeRepository.ListAsync();
|
||||
|
||||
var items = types
|
||||
.Select(type => new SelectListItem() { Value = type.Id.ToString(), Text = type.Type })
|
||||
.OrderBy(t => t.Text)
|
||||
.ToList();
|
||||
var items = types
|
||||
.Select(type => new SelectListItem() { Value = type.Id.ToString(), Text = type.Type })
|
||||
.OrderBy(t => t.Text)
|
||||
.ToList();
|
||||
|
||||
var allItem = new SelectListItem() { Value = null, Text = "All", Selected = true };
|
||||
items.Insert(0, allItem);
|
||||
var allItem = new SelectListItem() { Value = null, Text = "All", Selected = true };
|
||||
items.Insert(0, allItem);
|
||||
|
||||
return items;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user