public IActionResult EditMaterialLocation(int nID)
        {
            var result = new cListMaterialLocation();
            cTB_Material_Location EditMaterialLocation = new cTB_Material_Location();

            try
            {
                PTTGSP_DWSContext db = new PTTGSP_DWSContext();

                var lstMaterial_location = db.TB_Material_Location.Where(w => !w.IsDel && w.nLocationID == nID).ToList();
                EditMaterialLocation = (from a in lstMaterial_location.Where(w => !w.IsDel)
                                        select new cTB_Material_Location
                {
                    nLocationID = a.nLocationID,
                    sName = a.sName,
                    sDetail = a.sDetail,
                    bStatus = a.IsActive,
                    sStatus_Name = a.IsActive ? "ใช้งาน" : "ไม่ใช้งาน",
                    dUpdate = a.dUpdate,
                    sUpdate = a.dUpdate.ToString("dd/MM/yyyy", culture),
                }).FirstOrDefault();
            }
            catch (Exception e)
            {
                result.sStatus = SysFunc.process_Error;
                result.sMsg    = e.Message;
            }
            return(Ok(EditMaterialLocation));
        }
        public cListMaterialLocation GetListMaterialLocation(string txtSearch, string sIsActive)
        {
            var result = new cListMaterialLocation();

            try
            {
                PTTGSP_DWSContext db = new PTTGSP_DWSContext();

                var lstMaterial_location = db.TB_Material_Location.Where(w => !w.IsDel).ToList();
                var lstMaterial          = db.TB_Materials.Where(w => !w.IsDel).ToList();
                var Meterial_Location    = lstMaterial_location.Select(s => new lstMaterial_location
                {
                    nLocationID  = s.nLocationID,
                    sName        = s.sName,
                    sDetail      = s.sDetail,
                    bStatus      = s.IsActive,
                    sStatus_Name = s.IsActive ? "ใช้งาน" : "ไม่ใช้งาน",
                    dUpdate      = s.dUpdate,
                    sUpdate      = s.dUpdate.ToString("dd/MM/yyyy", culture),
                    IsUse        = lstMaterial.Where(w => w.nLocationID == s.nLocationID).FirstOrDefault() == null ? false : true
                                   //  IsUse = g.nLocationID == 0 ? false : true
                }).ToList();

                if (!string.IsNullOrEmpty(txtSearch) && txtSearch != "none")
                {
                    Meterial_Location = Meterial_Location.Where(item => item.sName.Trim().ToLower().Contains(txtSearch.Trim().ToLower())).ToList();
                }
                if (!string.IsNullOrEmpty(sIsActive))
                {
                    var isActive = sIsActive == "1";
                    Meterial_Location = Meterial_Location.Where(a => a.bStatus == isActive).ToList();
                }

                result.lstMaterial_location = Meterial_Location.ToList();
            }
            catch (Exception e)
            {
                result.sStatus = SysFunc.process_Error;
                result.sMsg    = e.Message;
            }
            return(result);
        }