public ActionResult AssignRoles(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(new HttpUnauthorizedResult());
            }
            var user = User.Identity as FormsIdentity;

            ViewBag.User = Membership.GetUser(userName);

            string[] roles         = Roles.GetAllRoles();
            string[] selectedRoles = Roles.GetRolesForUser(userName);

            List <SelectListItem> selectListItems = new List <SelectListItem>();

            foreach (var role in roles)
            {
                SelectListGroup selectListGroup = new SelectListGroup {
                    Name = "roles"
                };
                selectListItems.Add(new SelectListItem()
                {
                    Group    = selectListGroup,
                    Value    = role,
                    Text     = role,
                    Selected = selectedRoles.Any(r => r == role)
                });
            }
            return(View(new SelectList(selectListItems)));
        }
示例#2
0
        public OptionList ConcatDynamicList <TGroupKey, TKey, TValue>(IEnumerable <IGrouping <TGroupKey, KeyValuePair <TKey, TValue> > > list)
        {
            if (list != null)
            {
                _dynamicList = new List <SelectListItem>();

                foreach (var group in list)
                {
                    var g = new SelectListGroup {
                        Name = ValueString(group.Key)
                    };

                    foreach (KeyValuePair <TKey, TValue> pair in group)
                    {
                        AddDynamicOption(new SelectListItem {
                            Group = g,
                            Text  = ValueString(pair.Value),
                            Value = ValueString(pair.Key)
                        });
                    }
                }
            }

            return(this);
        }
示例#3
0
        // GET: Events/Create
        public async Task <IActionResult> Create()
        {
            List <Category> parentCategories = await _context.Categories.Where(p => p.ParentCategoryId == 0).ToListAsync();

            List <SelectListGroup> selectListGroups = new List <SelectListGroup>();

            for (int i = 0; i < parentCategories.Count(); i++)
            {
                SelectListGroup selectGroup = new SelectListGroup {
                    Name = parentCategories[i].Name
                };
                selectListGroups.Add(selectGroup);
            }

            List <Category> categories = await _context.Categories.Where(p => p.ParentCategoryId != 0).ToListAsync();

            var selectCategories = new List <SelectListItem>();

            foreach (var item in categories)
            {
                string         groupName      = _context.Categories.Find(item.ParentCategoryId).Name;
                SelectListItem selectListItem = new SelectListItem {
                    Text = item.Name, Value = item.Id.ToString(), Group = selectListGroups.FirstOrDefault(x => x.Name == groupName), Selected = false
                };
                selectCategories.Add(selectListItem);
            }
            SelectListItem selectList = new SelectListItem();

            selectCategories.Insert(0, selectList);

            ViewBag.Categories = selectCategories;
            return(View());
        }
        private static void BuildThreeTierSelectList(List <TaxonomyLeaf> taxonomyLeafs,
                                                     Dictionary <string, SelectListGroup> groups, List <SelectListItem> selectListItems)
        {
            foreach (var taxonomyTrunkGrouping in taxonomyLeafs.GroupBy(x => x.TaxonomyBranch.TaxonomyTrunk)
                     .OrderBy(x => x.Key.TaxonomyTrunkSortOrder).ThenBy(x => x.Key.GetDisplayName()))
            {
                foreach (var taxonomyBranchGrouping in taxonomyTrunkGrouping.GroupBy(x => x.TaxonomyBranch)
                         .OrderBy(x => x.Key.TaxonomyBranchSortOrder).ThenBy(x => x.Key.GetDisplayName()))
                {
                    var taxonomyBranch  = taxonomyBranchGrouping.Key;
                    var displayName     = $"{taxonomyBranch.TaxonomyTrunk.GetDisplayName()} - {taxonomyBranch.GetDisplayName()}";
                    var selectListGroup = new SelectListGroup()
                    {
                        Name = displayName
                    };
                    groups.Add(displayName, selectListGroup);

                    foreach (var taxonomyLeaf in taxonomyBranchGrouping.OrderBy(x => x.TaxonomyLeafSortOrder).ThenBy(x => x.GetDisplayName()))
                    {
                        selectListItems.Add(new SelectListItem()
                        {
                            Value = taxonomyLeaf.TaxonomyLeafID.ToString(),
                            Text  = taxonomyLeaf.GetDisplayName(),
                            Group = selectListGroup
                        });
                    }
                }
            }
        }
示例#5
0
        public void OnGet(long id)
        {
            Role        = _roleApplication.GetDetails(id);
            Permissions = new List <SelectListItem>();

            foreach (var exposer in _permissionExposer)
            {
                var exposedPermission = exposer.Expose();
                foreach (var(key, value) in exposedPermission)
                {
                    var group = new SelectListGroup()
                    {
                        Name = key
                    };
                    foreach (var permission in value)
                    {
                        var item = new SelectListItem(permission.Name, permission.Code.ToString())
                        {
                            Group = group
                        };

                        if (Role.MappedPermissions.Any(x => x.Code == permission.Code))
                        {
                            item.Selected = true;
                        }

                        Permissions.Add(item);
                    }
                }
            }
        }
示例#6
0
        private List <SelectListItem> BuildCustomers()
        {
            var customers = from p in _pinhuaContext.往来单位.ToList()
                            select p;

            var groups = from p in customers
                         orderby p.Rank descending
                         group p by p.Rank into g
                         select g.Key;
            var groupingCustomers = new List <SelectListItem>();

            foreach (var key in groups)
            {
                var optGroup = new SelectListGroup
                {
                    Name = key?.ToString()
                };
                foreach (var customer in customers)
                {
                    if (customer.Rank == key)
                    {
                        groupingCustomers.Add(new SelectListItem
                        {
                            Group = optGroup,
                            Text  = customer.单位编号 + " - " + customer.单位名称,
                            Value = customer.单位编号
                        });
                    }
                }
            }
            return(groupingCustomers);
        }
示例#7
0
                SelectListGroup NewGroup(string name)
                {
                    SelectListGroup ret = StringToGroup(name);

                    groups.Add(ret);
                    return(ret);
                }
示例#8
0
        private List <SelectListItem> BuildTypes()
        {
            var types = (from p in _pinhuaContext.业务类型.AsNoTracking()
                         where p.状态 == "Yes" && p.MvP == "GI"
                         select p).ToList();
            var groups = from p in types
                         group p by p.MvP into g
                         select g.Key;
            var groupingTypes = new List <SelectListItem>();

            foreach (var group in groups)
            {
                var optGroup = new SelectListGroup
                {
                    Name = group
                };
                foreach (var option in types)
                {
                    if (option.MvP == group)
                    {
                        groupingTypes.Add(new SelectListItem
                        {
                            Group = optGroup,
                            Text  = option.业务类型1 + " - " + option.类型描述,
                            Value = option.业务类型1,
                        });
                    }
                }
            }
            return(groupingTypes);
        }
示例#9
0
        private ICollection <SelectListItem> MapSelectListItemsBySubreddits(
            IEnumerable <Subreddit> subreddits,
            string groupName,
            string selectedSubredditId)
        {
            var models = new List <SelectListItem>();
            var group  = new SelectListGroup
            {
                Name = groupName
            };

            if (subreddits.Count() == 0)
            {
                var text = ModelsConstants.SelectListItemNameEmpty;
                var initialCreatedItem = this.CreateEmptySelectListItem(groupName, text);
                models.Add(initialCreatedItem);
            }

            foreach (var subreddit in subreddits)
            {
                var selectListItem = this.MapSelectListItemBySubreddit(subreddit, group, selectedSubredditId);
                models.Add(selectListItem);
            }

            return(models);
        }
示例#10
0
        public List <SelectListItem> GetRolesSelect()
        {
            List <SelectListItem> rolessel = new List <SelectListItem>();
            SelectListItem        role;
            SelectListGroup       group = new SelectListGroup {
                Name = "todos", Disabled = false
            };


            SqlDataReader data = SqlHelper.ExecuteReader(MySettings.ConnEAMAdmin
                                                         , "dbo.admin_GetRoles"
                                                         , ""
                                                         , 0);


            if (data.HasRows)
            {
                while (data.Read())
                {
                    role       = new SelectListItem();
                    group.Name = data["grupo"].ToString();
                    role.Group = group;
                    role.Value = data["roleid"].ToString();
                    role.Text  = data["rolenombre"].ToString();

                    rolessel.Add(role);
                }
            }
            data.Close();

            return(rolessel);
        }
        /// <summary>
        /// Generate a dropdown list of courses to pick from based on the list of available courses and course groups within the database.
        /// Additionally segments the courses into the course groups defined in the database to make courses easier to find.
        /// </summary>
        /// <param name="courses">List of courses to include in the drop down</param>
        /// <param name="groups">List of groups to segment the courses into</param>
        /// <param name="selectedCourseId">Pre-select a course if it has been selected previously</param>
        /// <returns>A dropdown list of available courses to apply for.</returns>
        public static IEnumerable <SelectListItem> ToSelectList(this List <Course> courses, List <CourseGroup> groups, int?selectedCourseId)
        {
            // Order the courses into groups in the select list, following the same groups as the overall course groups.
            List <SelectListGroup> selectGroups = new List <SelectListGroup>();

            if (groups != null && groups.Any())
            {
                groups.ForEach(g => selectGroups.Add(new SelectListGroup {
                    Name = g.Name
                }));
            }

            // Convert each course into an item in the select list
            foreach (Course course in courses)
            {
                // Find the group that this course belongs to, if any.
                CourseGroup     courseGroup = groups.FirstOrDefault(g => g.Id == course.Type);
                SelectListGroup selectGroup = selectGroups.FirstOrDefault(g => courseGroup != null && g.Name == courseGroup.Name);

                yield return(new SelectListItem {
                    Value = course.Id.ToString(),
                    Text = course.Title,
                    Selected = selectedCourseId.HasValue ? selectedCourseId.Value == course.Id : false,
                    Group = selectGroup
                });
            }
        }
        public void OnGet(long id)
        {
            Command = _roleApplication.GetDetails(id);
            var permissions = new List <PermissionDto>();

            foreach (var exposition in _exposition)
            {
                var exposedPermissions = exposition.Expose();
                foreach (var(key, value) in exposedPermissions)
                {
                    permissions.AddRange(value);
                    var group = new SelectListGroup
                    {
                        Name = key
                    };
                    foreach (var permission in value)
                    {
                        var item = new SelectListItem(permission.Name, permission.Code.ToString())
                        {
                            Group = group
                        };

                        if (Command.MappedPermissions.Any(x => x.Code == permission.Code))
                        {
                            item.Selected = true;
                        }
                        Permissions.Add(item);
                    }
                }
            }
        }
示例#13
0
        // GET: Customers/Gestion_Cobro
        public ActionResult Index()
        {
            var clientes = new List <SelectListItem>();

            foreach (var cliente in db.Clientes.Where(c => c.activo && !c.eliminado).OrderBy(c => c.nombre))
            {
                var group = new SelectListGroup()
                {
                    Name = cliente.nombre
                };
                foreach (var razon_social in cliente.Razones_Sociales.Where(r => r.activo && !r.eliminado).OrderBy(r => r.razon_social))
                {
                    clientes.Add(new SelectListItem()
                    {
                        Text  = razon_social.razon_social,
                        Value = razon_social.id_razon_social.ToString(),
                        Group = group
                    });
                }
            }
            ViewBag.id_razon_social        = clientes;
            ViewBag.tipo_gestion           = new SelectList(db.Cat_Tipos_Gestion.Where(e => e.activo), "id_cat_tipo_gestion", "nombre");
            ViewBag.tipo_respuesta_gestion = new SelectList(db.Cat_Tipos_Respuesta_Gestion.Where(e => e.activo), "id_cat_tipo_respuesta_gestion", "nombre");
            return(View());
        }
        public ActionResult add()
        {
            SelectListGroup slg = new SelectListGroup();

            slg.Name = "可选应用";

            var apps = (from t in userHelper.getApps()
                        select new SelectListItem
            {
                Text = t.name,
                Value = t.ID.ToString(),
                //Group = slg
            }).ToList();


            apps.ForEach(t => t.Group = slg);
            apps.Insert(0, new SelectListItem {
                Text = "请选择被测应用", Value = ""
            });

            // var apps = userHelper.getApps().ToDictionary(k => k.ID, v => v.name);
            ViewBag.apps = apps;

            return(View());
        }
        public List <SelectListItem> PopulateCRFGroupedCategoriesDropdownList()
        {
            var categories = _context.CaseReportForms
                             .Include(f => f.CaseReportFormCategory)
                             .GroupBy(f => f.CaseReportFormCategoryId)
                             .ToList();

            var categoriesList = new List <SelectListItem>();

            foreach (var catGroup in categories)
            {
                var categoryId    = catGroup.Key;
                var categoryModel = _context.CaseReportFormCategories
                                    .Where(c => c.ID == categoryId)
                                    .FirstOrDefault();
                var group = new SelectListGroup {
                    Name = categoryModel.Name
                };

                foreach (var form in catGroup)
                {
                    var formListItem = new SelectListItem()
                    {
                        Value = form.ID.ToString(),
                        Text  = form.Name,
                        Group = group
                    };
                    categoriesList.Add(formListItem);
                }
            }
            return(categoriesList);
        }
        /// <summary>
        /// Method gets all objects form departments and institutions and coverts them to a viewmodel.
        /// </summary>
        /// <returns></returns>
        public IActionResult Create()
        {
            // Retrieve for dropdown
            List <Department>  departments  = departmentRepository.GetAll();
            List <Institution> institutions = institutionRepository.GetAll();

            List <SelectListItem> items = new List <SelectListItem>();
            SelectListGroup       group;

            // Create dropdownlist for treatmenttype
            foreach (Institution i in institutions)
            {
                group = new SelectListGroup
                {
                    Name = i.Name
                };

                foreach (Department dm in departments.Where(d => d.InstitutionId == i.Id))
                {
                    items.Add(new SelectListItem
                    {
                        Value = dm.Id.ToString(),
                        Text  = dm.Name,
                        Group = group
                    });
                }
            }

            TreatmentTypeDetailViewModel vm = new TreatmentTypeDetailViewModel
            {
                Departments = items
            };

            return(View(vm));
        }
示例#17
0
        public static List <SelectListItem> GetSelectListItems()
        {
            SelectListGroup slgroup1 = new SelectListGroup()
            {
                Name = "German Cars"
            };
            SelectListGroup slgroup2 = new SelectListGroup()
            {
                Name = "Swedish Cars"
            };

            return(new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Group = slgroup1, Text = "Volvo", Value = "1"
                },
                new SelectListItem()
                {
                    Group = slgroup1, Text = "Mercedes-Benz", Value = "2"
                },
                new SelectListItem()
                {
                    Group = slgroup2, Text = "Saab", Value = "3"
                },
                new SelectListItem()
                {
                    Group = slgroup2, Text = "Audi", Value = "4"
                }
            });
        }
示例#18
0
        internal static string ListItemToOption(SelectListItem item, SelectListGroup optGroup)
        {
            TagBuilder builder = new TagBuilder("option")
            {
                InnerHtml = HttpUtility.HtmlEncode(item.Text)
            };

            if (item.Value != null)
            {
                builder.Attributes["value"] = item.Value;
            }
            if (item.Selected)
            {
                builder.Attributes["selected"] = "selected";
            }
            if (item.Disabled)
            {
                builder.Attributes["disabled"] = "disabled";
            }

            if (optGroup != null && !string.IsNullOrEmpty(optGroup.Name))
            {
                builder.Attributes["data-tokens"] = $"{item.Text} {optGroup.Name}";
            }
            else
            {
                builder.Attributes["data-tokens"] = item.Text;
            }
            return(builder.ToString(TagRenderMode.Normal));
        }
示例#19
0
            public List <SelectListItem> BuildDaysTimes()
            {
                if (_convention.Days is null)
                {
                    return(new List <SelectListItem>());
                }

                var items = new List <SelectListItem>();

                foreach (var day in _convention.Days.OrderBy(x => x.Date))
                {
                    var group = new SelectListGroup
                    {
                        Name = day.GetDescription()
                    };

                    var timeSlots = _factory.GenerateTimeSlots(day.StartTime, day.EndTime, day.TimeSlotStrategy);
                    foreach (var starTime in timeSlots.StartTimeAndDurations.Keys)
                    {
                        var item = new SelectListItem
                        {
                            Value = $"{day.Id},{starTime.ToString("HH:mm", CultureInfo.CurrentCulture)}",
                            Text  = $"{starTime.ToString("HH:mm", CultureInfo.CurrentCulture)}",
                            Group = group
                        };
                        items.Add(item);
                    }
                }

                return(items);
            }
示例#20
0
        public IActionResult Edit(int id)
        {
            var productViewModel = new ProductViewModel();

            productViewModel.Product    = db.Products.Find(id);
            productViewModel.Categories = new List <SelectListItem>();

            var categories = db.Categories.ToList();

            foreach (var category in categories)
            {
                var group = new SelectListGroup {
                    Name = category.Name
                };
                if (category.InverseParents != null && category.InverseParents.Count() != 0)
                {
                    foreach (var subCategory in category.InverseParents)
                    {
                        var selectListItem = new SelectListItem
                        {
                            Text  = subCategory.Name,
                            Value = subCategory.Id.ToString(),
                            Group = group
                        };

                        productViewModel.Categories.Add(selectListItem);
                    }
                }
            }
            return(View("Edit", productViewModel));
        }
示例#21
0
            public List <SelectListItem> BuildHalls()
            {
                if (_convention.Halls is null)
                {
                    return(new List <SelectListItem>());
                }

                var items = new List <SelectListItem>();

                foreach (var halls in _convention.Halls.OrderBy(x => x.FirstTable))
                {
                    var group = new SelectListGroup {
                        Name = halls.Name
                    };
                    foreach (var table in halls.Tables.OrderBy(x => x))
                    {
                        var item = new SelectListItem
                        {
                            Value = $"{halls.Id},{table}",
                            Text  = $"שולחן {table}",
                            Group = group
                        };
                        items.Add(item);
                    }
                }

                return(items);
            }
示例#22
0
        private async Task <NewsViewModel> BuildEditNewsFeedViewModel()
        {
            var newsFeedViewModel = new NewsViewModel();
            var elections         = await _electionsRepository.GetElectionsForNewsFeed();

            newsFeedViewModel.Elections = new List <SelectListItem>();
            foreach (var election in elections.Value)
            {
                var electionGroup = new SelectListGroup {
                    Name = election.ElectionName
                };
                foreach (var ballot in election.Ballots)
                {
                    newsFeedViewModel.Elections.Add(new SelectListItem(ballot.Name, ballot.BallotId.ToString())
                    {
                        Group = electionGroup
                    });
                }
            }
            newsFeedViewModel.Date = DateTime.Now;

            newsFeedViewModel.SelectedElectionId = null;
            var authors = await _authorsRepository.GetAuthors();

            newsFeedViewModel.Authors = authors.Select(a => new SelectListItem(a.Name, a.Id.ToString())).ToList();
            return(newsFeedViewModel);
        }
示例#23
0
        public async Task <PrePlanningLookUpsModels> GetLookUpsAsync()
        {
            PrePlanningLookUpsModels lookUps = await _cache.GetOrCreateAsync(CacheKeys.PrePlanningCache /* + "_" + HttpContext.Session.Id*/, async entry =>
            {
                int minutes             = int.Parse(_rootConfiguration.CachingConfiguration.CachingMinutes /*_configuration.GetSection("Chaching:CachingMinutes").Value*/);
                entry.SlidingExpiration = TimeSpan.FromMinutes(minutes);
                return(await _ApiClient.GetAsync <PrePlanningLookUpsModels>("Lookup/GetPrePlanningLookups", null));
            });

            List <SelectListItem> activitiesItems = new List <SelectListItem>();

            foreach (var item in lookUps.ProjectTypes)
            {
                var group = new SelectListGroup {
                    Name = item.Name
                };
                foreach (var sub in item.SubActivities)
                {
                    activitiesItems.Add(new SelectListItem {
                        Value = sub.ActivityId.ToString(), Text = sub.Name, Group = group
                    });
                }
            }
            lookUps.ProjectTypesList = activitiesItems;
            return(lookUps);
        }
示例#24
0
        private ProjectAndTagsViewModel CreateProjectAndTagsViewModelForEntry()
        {
            Random                r          = new Random();
            List <Tag>            allTags    = _db.Tags.OrderBy(x => x.Name).ToList();
            List <SelectListItem> tagsChoice = new List <SelectListItem>();
            SelectListGroup       group1     = new SelectListGroup {
                Name = "group1"
            };

            foreach (var t in allTags)
            {
                SelectListItem tag = new SelectListItem
                {
                    Text     = t.Name,
                    Value    = t.Name,
                    Selected = false,
                    Disabled = false
                               //Group = group1
                };

                tagsChoice.Add(tag);
            }

            ProjectAndTagsViewModel patvm = new ProjectAndTagsViewModel
            {
                ProjectTags     = allTags,
                AllTags         = allTags,
                TagsSelectItems = tagsChoice,
                IdNo            = r.Next(1, System.Int32.MaxValue - 1)
            };

            return(patvm);
        }
        public static IEnumerable <SelectListItem> ConvertToSelectList <T, U>(this IEnumerable <IGrouping <T, U> > data, U selectedItem = null, IEnumerable <U> disabledItems = null)
            where T : INameId
            where U : class, INameId
        {
            List <SelectListItem> l = new List <SelectListItem>();

            foreach (var cat in data)
            {
                SelectListGroup group = new SelectListGroup()
                {
                    Name = cat.Key.Name
                };

                foreach (var item in cat)
                {
                    l.Add(new SelectListItem()
                    {
                        Text     = item.Name,
                        Value    = item.Id.ToString(),
                        Selected = selectedItem != null ? selectedItem.Id == item.Id : false,
                        Group    = group,
                        Disabled = disabledItems != null ? disabledItems.Select(x => x.Id).Contains(item.Id) : false
                    });
                }
            }

            return(l);
        }
示例#26
0
        // GET: DeployTypes/CreateNew
        public IActionResult CreateNew(int Id)
        {
            //DeployType Deploy = new DeployType { TennantID = Id };
            var tennant    = _context.Tennants.Where(d => d.TennantID == Id).FirstOrDefault();
            var deploylist = _context.DeployList.ToList();
            var viewModel  = new DeployChoiceViewModel();

            viewModel.DeployList     = new List <DeployList>();
            viewModel.DeployListItem = new List <SelectListItem>();
            viewModel.TennantID      = Id;
            viewModel.TennantName    = tennant.TennantName;
            viewModel.DeploySaved    = "No";
            foreach (var group in deploylist.GroupBy(item => item.DeployType))
            {
                SelectListGroup listGroup = new SelectListGroup()
                {
                    Name = group.Key
                };

                foreach (var item in group)
                {
                    viewModel.DeployListItem.Add(new SelectListItem
                    {
                        Text  = item.DeployValue,
                        Value = item.DeployName,
                        Group = listGroup
                    });
                }
                ;
            }
            return(View(viewModel));
        }
示例#27
0
        public ActionResult Authorize(int id)
        {
            Role role = roleService.GetRole(id);

            var groups = permissionService.GetPermissions().GroupBy(p => p.Category);

            List <SelectListItem> selectListItems = new List <SelectListItem>();

            foreach (var group in groups)
            {
                SelectListGroup selectListGroup = new SelectListGroup {
                    Name = group.Key
                };
                selectListItems.AddRange(group.Select(g => new SelectListItem
                {
                    Group    = selectListGroup,
                    Selected = role.Permissions.Any(rp => rp.ID == g.ID),
                    Value    = g.ID.ToString(),
                    Text     = g.Description
                }));
            }

            ViewBag.RoleName = role.Name;

            return(View(new SelectList(selectListItems)));
        }
示例#28
0
        private IEnumerable <SelectListItem> DaysInWeek(DateTime startTime, params DayOfWeek[] daysOfWeek)
        {
            var             currentDay = startTime.Date;
            SelectListGroup group      = null;

            while (true)
            {
                if (currentDay.DayOfWeek == DayOfWeek.Sunday || group == null)
                {
                    var beginningOfWeek = DateTimeHelper.GetBeginningOfWeek(currentDay);
                    group = new SelectListGroup {
                        Name = beginningOfWeek.ToString("MMM-dd")
                    };
                }

                if (daysOfWeek.Contains(currentDay.DayOfWeek))
                {
                    var existingRoutes  = string.Join(", ", ScheduleProvider.Get(currentDay, TimeSpan.FromDays(1)).Select(schedule => schedule.Route.Name));
                    var scheduledRoutes = string.IsNullOrEmpty(existingRoutes) ? string.Empty : $" - ({existingRoutes})";
                    yield return(new SelectListItem($"{currentDay:dddd M-d}{scheduledRoutes}", currentDay.Date.ToString())
                    {
                        Group = group
                    });
                }

                currentDay = currentDay.AddDays(1);
            }
        }
示例#29
0
        private void SetPageData()
        {
            var dbs = _db.Dbs.Where(x => x.IsValid)
                      .Include(x => x.Tables)
                      .ToList();

            var data = new List <SelectListItem>();

            foreach (var db in dbs)
            {
                var group = new SelectListGroup {
                    Name = db.Title
                };
                if (db.Tables != null && db.Tables.Count > 0)
                {
                    foreach (var table in db.Tables)
                    {
                        data.Add(new SelectListItem(table.Title, table.Id.ToString())
                        {
                            Group = group
                        });
                    }
                }
            }

            ViewBag.Dbs = data;
        }
        public IActionResult Add()
        {
            try
            {
                var accountVendor    = ocmde.AccountVendors.SingleOrDefault(v => v.Email.Equals(HttpContext.Session.GetString("email_vendor")));
                var productViewModel = new ProductViewModel();
                productViewModel.Categories = new System.Collections.Generic.List <SelectListItem>();
                var categories = ocmde.Categories.Where(c => c.ParentId == null).ToList();
                foreach (var category in categories)
                {
                    var group = new SelectListGroup {
                        Name = category.Name
                    };
                    foreach (var subCategory in category.InverseParents)
                    {
                        if (subCategory.VendorId == accountVendor.VendorId || (subCategory.VendorId == null && subCategory.ParentId != null))
                        {
                            var selectListItem = new SelectListItem()
                            {
                                Text  = subCategory.Name,
                                Value = subCategory.Id.ToString(),
                                Group = group
                            };
                            productViewModel.Categories.Add(selectListItem);
                        }
                    }
                }

                return(View("Add", productViewModel));
            }
            catch (Exception e)
            {
                throw;
            }
        }
示例#31
0
        public CountryViewModelGroup()
        {
            var NorthAmericaGroup = new SelectListGroup { Name = "North America" };
            var EuropeGroup = new SelectListGroup { Name = "Europe" };

            Countries = new List<SelectListItem>
            {
                new SelectListItem
                {
                    Value = "MEX",
                    Text = "Mexico",
                    Group = NorthAmericaGroup
                },
                new SelectListItem
                {
                    Value = "CAN",
                    Text = "Canada",
                    Group = NorthAmericaGroup
                },
                new SelectListItem
                {
                    Value = "US",
                    Text = "USA",
                    Group = NorthAmericaGroup
                },
                new SelectListItem
                {
                    Value = "FR",
                    Text = "France",
                    Group = EuropeGroup
                },
                new SelectListItem
                {
                    Value = "ES",
                    Text = "Spain",
                    Group = EuropeGroup
                },
                new SelectListItem
                {
                    Value = "DE",
                    Text = "Germany",
                    Group = EuropeGroup
                }
          };
        }