﻿using OREM_STAT.db;
using OREM_STAT.Model;
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;

namespace OREM_STAT.ViewModel
{
    internal class UnitViewModel
    {
        private dbConnectLocalDB _dbConnect;
        public List<UnitModel> Collect { get; set; }

        public UnitViewModel()
        {
            _dbConnect = new dbConnectLocalDB();
            Collect = _dbConnect.GetTable("SELECT * FROM [units];")
                .AsEnumerable()
                .Select(res => new UnitModel()
                {
                    Id = res.Field<Int32>("id"),
                    Name = res.Field<String>("unit")
                }).ToList();
        }
    }
}
