Exemplo n.º 1
0
        public VendorIndexViewModel(List<Vendor> topvendors)
        {
            Vendors = new List<VendorSummaryViewModel> { };

            foreach (var v in topvendors)
            {
                VendorSummaryViewModel vs = new VendorSummaryViewModel(v);
                Vendors.Add(vs);
            }
        }
Exemplo n.º 2
0
        public VendorIndexViewModel(string query)
        {
            Vendors = new List<VendorSummaryViewModel> { };
            var _vendors = from v in db.Vendors
                            select v;


            //Filtering items if there is a search query.
            if (!String.IsNullOrEmpty(query))
            {
                _vendors = _vendors.Where(s => s.Name.ToUpper().Contains(query.ToUpper()) ||
                s.Email.ToUpper().Contains(query.ToUpper()) || s.ContactName.ToUpper().Contains(query.ToUpper()) || 
                s.VendorNotes.ToUpper().Contains(query.ToUpper())).OrderBy(n => n.Name);
            }

            foreach (var v in _vendors.ToList())
            {
                VendorSummaryViewModel vs = new VendorSummaryViewModel(v);
                Vendors.Add(vs);
            }
        }