public Customers GetCustomersById(RQ_Customer _objcust) { if (_objcust.CustId != null) { using (LocalEntity _context = new LocalEntity()) { //var search = _context.tblCustomers.(); var search = (from x in _context.tblCustomers where x.Id == _objcust.CustId select x).AsQueryable(); var result = (from s in search select new Customers { Id = s.Id, Address = s.Address, ContactPerson = s.ContactPerson, Country = s.Country, CustomerCode = s.CustomerCode, CustomerName = s.CustomerName, IsActive = s.IsActive ?? true, MobileNo = s.MobileNo }).FirstOrDefault(); return(result); } } return(new Customers() { }); }
public List <RS_Customers> GetCustomers(RQ_Customer _objcust) { List <RS_Customers> _lstCust = new List <RS_Customers>(); try { using (LocalEntity _context = new LocalEntity()) { var search = _context.tblCustomers.AsQueryable(); if (!string.IsNullOrWhiteSpace(_objcust.CustomerName)) { search = (from x in search where x.CustomerName == _objcust.CustomerName select x).AsQueryable(); } if (_objcust.CustId != null) { search = (from x in search where x.Id == _objcust.CustId select x).AsQueryable(); } int total = search.Count(); int skip = (_objcust.PageNo * (_objcust.PageSize ?? 5) ?? 0); _lstCust = (from s in search select new RS_Customers() { Id = s.Id, Address = s.Address, ContactPerson = s.ContactPerson, Country = s.Country, CustomerCode = s.CustomerCode, CustomerName = s.CustomerName, IsActive = s.IsActive ?? true, MobileNo = s.MobileNo }).OrderBy(x => x.CustomerName).Skip(skip).ToList(); } } catch (Exception) { throw; } return(_lstCust); }