Пример #1
0
        // GET api/<controller>
        public SelectItemsVM Get()
        {
            //Connet to db
            EarthSkyTimeEntities1 estEnt = new EarthSkyTimeEntities1();

            SelectItemsVM locations = new SelectItemsVM();

            locations.SelectItemsVMList = new List <SelectItemVM>();

            // Get the customers
            var oCust = from c in estEnt.Locations
                        orderby c.LocationName
                        select new { c.LocationName, c.LocationID };

            locations.SelectItemsVMList.Add(new SelectItemVM {
                Text = "-- Choose Location --", Value = "0"
            });
            foreach (var o in oCust)
            {
                locations.SelectItemsVMList.Add(new SelectItemVM {
                    Text = o.LocationName, Value = o.LocationID.ToString()
                });
            }

            return(locations);
        }
Пример #2
0
        // GET api/<controller>


        public SelectItemsVM GetAllCustomers()
        {
            //Connet to db
            EarthSkyTimeEntities1 estEnt = new EarthSkyTimeEntities1();

            SelectItemsVM customers = new SelectItemsVM();

            customers.SelectItemsVMList = new List <SelectItemVM>();

            // Get the customers
            var oCust = from c in estEnt.Customers
                        orderby c.LastName
                        select new { c.LastName, c.FirstName, c.CustomerID };

            customers.SelectItemsVMList.Add(new SelectItemVM {
                Text = "-- Choose Customer --", Value = "0"
            });


            foreach (var o in oCust)
            {
                customers.SelectItemsVMList.Add(new SelectItemVM {
                    Text = o.LastName + ", " + o.FirstName, Value = o.CustomerID.ToString()
                });
            }

            return(customers);
        }