public PartyMaster GetPartyMasterByID(PartyMasterRQ _objSearch) { PartyMaster _PartyMaster = new PartyMaster(); try { using (LocalEntity _context = new LocalEntity()) { var search = from s in _context.tblPartyMasters select s; if (_objSearch.PartyId > 0) { search = from s in search where s.PartyId == _objSearch.PartyId select s; } if (!string.IsNullOrWhiteSpace(_objSearch.PartyCode)) { search = from s in search where s.PartyCode == _objSearch.PartyCode select s; } _PartyMaster = (from s in search select new PartyMaster() { PartyCode = s.PartyCode, PartyName = s.PartyName, PartyId = s.PartyId, Address = s.Address, ContactPerson = s.ContactPerson, Email = s.Email, Fax = s.Fax, IsActive = s.IsActive, Mobile = s.Mobile, Pager = s.Pager, Phone = s.Phone }).FirstOrDefault(); } } catch (Exception) { throw; } return(_PartyMaster); }
public List <PartyMasterRS> GetPartyMaster(PartyMasterRQ _objSearch) { List <PartyMasterRS> _lstPartyMaster = new List <PartyMasterRS>(); try { using (LocalEntity _context = new LocalEntity()) { var search = _context.tblPartyMasters.AsQueryable(); if (!string.IsNullOrWhiteSpace(_objSearch.PartyName)) { search = (from x in search where x.PartyName.Contains(_objSearch.PartyName) select x); } if (!string.IsNullOrWhiteSpace(_objSearch.PartyCode)) { search = (from x in search where x.PartyCode == _objSearch.PartyCode select x); } _lstPartyMaster = (from s in search select new PartyMasterRS() { PartyCode = s.PartyCode, PartyName = s.PartyName, PartyId = s.PartyId }).OrderBy(x => x.PartyName).ToList(); } } catch (Exception) { throw; } return(_lstPartyMaster); }