RoadTypeDs.cs 782 Bytes
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MapsDb.Interfaces;
using MapsDb.Models;
using MapsModels.DsModels;
namespace MapsDb.DataService
{
    public class RoadTypeDs : IRoadTypeDs
    {
        private PostgresDbContext _context;
        public RoadTypeDs(){
            _context = new PostgresDbContext();
        }
        public Task<IList<RoadTypeSelectListDsM>> GetSelectListAsync(){
            return Task.Factory.StartNew(GetSelectList);
        }
        private IList<RoadTypeSelectListDsM> GetSelectList()
        {
           return _context.RoadType.Select(x => new RoadTypeSelectListDsM
            {
                RoadTypeId = x.RoadTypeId, 
                Name = x.Value
            }).ToList();
        }

    }
}