Пример #1
0
        /// <summary>
        /// Populates the check boxes for create.
        /// Defalts al checkboxes to false
        /// </summary>
        /// <returns>List of checkbox list items.</returns>
        private static List<CheckBoxListInfo> PopulateCheckBoxesForCreate()
        {
            List<UserWebSite> userWebSites = GetUserWebSitesWithDefaultDetails();

            List<CheckBoxListInfo> checkBoxListItems = new List<CheckBoxListInfo>();
            foreach (UserWebSite userWebSite in userWebSites)
            {
                CheckBoxListInfo info =
                   new CheckBoxListInfo(userWebSite.WebSiteId.ToString(), userWebSite.SiteName, false);
                checkBoxListItems.Add(info);
            }

            return checkBoxListItems;
        }
Пример #2
0
        /// <summary>
        /// Gets the checked boxes.
        /// </summary>
        /// <param name="selectedObjects">The selected objects.</param>
        /// <returns>List of check box items.</returns>
        private static List<CheckBoxListInfo> GetCheckedBoxes(string[] selectedObjects)
        {
            List<UserWebSite> userWebSites = GetUserWebSitesWithDefaultDetails();

            List<CheckBoxListInfo> checkBoxListItems = new List<CheckBoxListInfo>();
            foreach (UserWebSite userWebSite in userWebSites)
            {
                bool isChecked = false;
                if (selectedObjects != null)
                {
                    var selectedObject = selectedObjects.Where(q => q == userWebSite.WebSiteId.ToString());
                    if (selectedObject != null)
                    {
                        isChecked = true;
                    }
                }

                CheckBoxListInfo info =
                   new CheckBoxListInfo(userWebSite.WebSiteId.ToString(), userWebSite.SiteName, isChecked);
                checkBoxListItems.Add(info);
            }

            return checkBoxListItems;
        }
Пример #3
0
        /// <summary>
        /// Edits the specified id.
        /// </summary>
        /// <param name="id">The identification value.</param>
        /// <returns>The view instance.</returns>
        public ActionResult Edit(string id)
        {            
            IUnitOfWorkFactory factory = new WebSiteUnitOfWorkFactory();
            IAspNetUnitOfWork unitOfWork = factory.GetAspNetUnitOfWork();

            AspnetUsers user = unitOfWork.GetById(id);
            ViewData["isAdministrator"] = Roles.IsUserInRole(user.Username, "Admin");

            List<UserWebSite> userWebSites = GetUserWebSitesWithDefaultDetails();
            List<CheckBoxListInfo> checkBoxListItems = new List<CheckBoxListInfo>();
            foreach (UserWebSite userWebSite in userWebSites)
            {
                bool isChecked = false;
                if (user.WebSites.Find(q => q.Id == userWebSite.WebSiteId) != null)
                {
                    isChecked = true;
                }

                CheckBoxListInfo info =
                   new CheckBoxListInfo(userWebSite.WebSiteId.ToString(), userWebSite.SiteName, isChecked);
                checkBoxListItems.Add(info);
            }

            ViewData["listItems"] = checkBoxListItems;

            return View(user);
        }