public DataTable GetSupplierList() { DataTable dtRet = new DataTable(); using (Models.TLGX_MAPPEREntities1 context = new Models.TLGX_MAPPEREntities1()) { var supplierData = (from s in context.Suppliers orderby s.Name ascending select new Models.BusinessEntity.Suppliers { Supplier_Id = s.Supplier_Id, Code = s.Code, Name = s.Name, SupplierType = s.SupplierType, SupplierOwner = s.SupplierOwner, Create_Date = s.Create_Date, Create_User = s.Create_User, Edit_Date = s.Edit_Date, Edit_User = s.Edit_User } ).ToList(); dtRet = ConversionClass.CreateDataTable(supplierData); return(dtRet); } }
// // gets Master City data for a particular Country Id public DataTable GetSupplierCountryMapping(SupplierDataMode DataMode, Guid?Supplier_Id, Guid Country_Id) { DataTable dtRet = new DataTable(); // need a nice way of handling this mode, talk to rubesh you could probably do it with nullable guid check try { using (TLGX_MAPPEREntities1 myEntity = new TLGX_MAPPEREntities1()) { var MasterData = new MasterDataContract(); if (DataMode == SupplierDataMode.AllSupplierSingleCountry) { var supplierCountryMapping = (from ct in myEntity.m_CountryMapping where ct.Country_Id == Country_Id orderby ct.SupplierName ascending select new CountryMappingE { CountryMapping_ID = ct.CountryMapping_Id, CountryCode = ct.CountryCode, CountryName = ct.CountryName, Edit_Date = ct.Edit_Date, Country_ID = ct.Country_Id, Create_Date = ct.Create_Date, Create_User = ct.Create_User, Edit_User = ct.Edit_User, Status = ct.Status, Supplier_ID = ct.Supplier_Id ?? Guid.Empty, Supplier_Name = ct.SupplierName }).ToList(); MasterData.CountryMappingL = supplierCountryMapping; dtRet = ConversionClass.CreateDataTable(supplierCountryMapping); } else if (DataMode == SupplierDataMode.SingleSupplierSingleCountry) { var supplierCountryMapping = (from ct in myEntity.m_CountryMapping where ct.Country_Id == Country_Id && ct.Supplier_Id == Supplier_Id orderby ct.CountryName ascending select new CountryMappingE { CountryMapping_ID = ct.CountryMapping_Id, CountryCode = ct.CountryCode, CountryName = ct.CountryName, Edit_Date = ct.Edit_Date, Country_ID = ct.Country_Id, Create_Date = ct.Create_Date, Create_User = ct.Create_User, Edit_User = ct.Edit_User, Status = ct.Status, Supplier_ID = ct.Supplier_Id ?? Guid.Empty, Supplier_Name = ct.SupplierName }).ToList(); MasterData.CountryMappingL = supplierCountryMapping; dtRet = ConversionClass.CreateDataTable(supplierCountryMapping); } else if (DataMode == SupplierDataMode.SingleSupplierAllCountry) { var supplierCountryMapping = (from ct in myEntity.m_CountryMapping where ct.Supplier_Id == Supplier_Id orderby ct.CountryName ascending select new CountryMappingE { CountryMapping_ID = ct.CountryMapping_Id, CountryCode = ct.CountryCode, CountryName = ct.CountryName, Edit_Date = ct.Edit_Date, Country_ID = ct.Country_Id, Create_Date = ct.Create_Date, Create_User = ct.Create_User, Edit_User = ct.Edit_User, Status = ct.Status, Supplier_ID = ct.Supplier_Id ?? Guid.Empty, Supplier_Name = ct.SupplierName }).ToList(); MasterData.CountryMappingL = supplierCountryMapping; dtRet = ConversionClass.CreateDataTable(supplierCountryMapping); } else if (DataMode == SupplierDataMode.AllSupplierAllCountry) { var supplierCountryMapping = (from ct in myEntity.m_CountryMapping orderby ct.CountryName ascending select new CountryMappingE { CountryMapping_ID = ct.CountryMapping_Id, CountryCode = ct.CountryCode, CountryName = ct.CountryName, Edit_Date = ct.Edit_Date, Country_ID = ct.Country_Id, Create_Date = ct.Create_Date, Create_User = ct.Create_User, Edit_User = ct.Edit_User, Status = ct.Status, Supplier_ID = ct.Supplier_Id ?? Guid.Empty, Supplier_Name = ct.SupplierName }).ToList(); MasterData.CountryMappingL = supplierCountryMapping; dtRet = ConversionClass.CreateDataTable(supplierCountryMapping); } ; } return(dtRet); } catch (Exception ex) { throw ex; } }