예제 #1
0
        private void FillViewBag()
        {
            var allCustomers = new CustomerDataService().GetAllCustomers().ToList();

            // Create a SelectListItem list from the alarm class configurations which are distinct by their names
            ViewBag.Customers =
                allCustomers.GroupBy(x => x.Id)
                .Select(x => x.FirstOrDefault()).Select(
                    x =>
                    new SelectListItem
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            })
                .ToList();

            ViewBag.SaleStates = EnumHelper.GetSelectList(typeof(SalesState));
            ViewBag.Currencies = EnumHelper.GetSelectList(typeof(Currency));

            var allExporters = new ExporterDataService().GetAllExporters().ToList();

            ViewBag.Exporters =
                allExporters.GroupBy(x => x.Id)
                .Select(x => x.FirstOrDefault()).Select(
                    x =>
                    new SelectListItem
            {
                Text  = x.Name,
                Value = x.Id.ToString()
            })
                .ToList();
        }