using AppData;
using NKC_SDK;
using System.Collections.Generic;
using System.Web.Http;

namespace NKC_WF.Controllers
{
    public class MaterialController : ApiController
    {
        /// <summary>
        /// oggetto static/singleton per fare chiamate sul datalayer
        /// </summary>
        protected DataLayer DLMan = new DataLayer();
        /// <summary>
        /// Restituisce ELENCO materiali
        /// </summary>
        /// <returns></returns>
        // GET: api/Material
        [HttpGet]
        public List<Material> Get()
        {
            List<Material> answ = new List<Material>();
            var table = DLMan.taMat.GetData();
            Material currMat = new Material();
            foreach (var item in table)
            {
                currMat = new Material()
                {
                    MatId = item.MatID,
                    MatDesc = item.MatDesc,
                    MatExtCode = item.MatExtCode,
                    MatDtmx = item.MatDtmx,
                    ApprovDate = item.ApprovDate,
                    ApprovUser = item.ApprovUser,
                    L_mm = item.L_mm,
                    W_mm = item.W_mm,
                    T_mm = item.T_mm
                };
                answ.Add(currMat);
            }
            return answ;
        }

    }
}
