예제 #1
0
        /// <summary>
        /// To Get dropdown list of bakery ids to choose one
        /// </summary>
        /// <param name="bakeryId">Id of the bakery from session state</param>
        /// <returns>List of dropdownlist items (for model)</returns>
        public List <SelectListItem> getDropDownListBakeryIDs(int?bakerySelected = null)
        {
            int bakeryId;
            List <SelectListItem> IDs     = new List <SelectListItem>();
            AddRoleDataContext    addRole = new AddRoleDataContext();

            foreach (string role in Roles.GetAllRoles())
            {
                string roleDescription = addRole.aspnet_Roles.Single(p => p.RoleName == role.ToString()).Description;

                if (int.TryParse(role, out bakeryId))
                {
                    SelectListItem id = new SelectListItem();
                    if (bakeryId == bakerySelected)
                    {
                        id.Selected = true;
                    }

                    id.Value = bakeryId.ToString();
                    if (roleDescription != null)
                    {
                        id.Text = roleDescription;
                    }
                    else
                    {
                        id.Text = bakeryId.ToString();
                    }
                    IDs.Add(id);
                }
            }
            return(IDs);
        }
예제 #2
0
        /// <summary>
        /// To Get dropdown list of roles to choose one
        /// </summary>
        /// <returns>List of dropdownlist items (for model)</returns>
        public List <SelectListItem> getDropDownListRoles(string selected = null)
        {
            int  bakeryId;
            bool first = true;
            List <SelectListItem> rolesList = new List <SelectListItem>();
            AddRoleDataContext    addRole   = new AddRoleDataContext();

            foreach (string role in Roles.GetAllRoles())
            {
                SelectListItem roleItem = new SelectListItem();
                if (role == selected)
                {
                    roleItem.Selected = true;
                }
                roleItem.Value = role;
                string roleDescription = addRole.aspnet_Roles.Single(p => p.RoleName == role.ToString()).Description;
                if (roleDescription != null)
                {
                    roleItem.Text = roleDescription;
                }
                else
                {
                    roleItem.Text = role;
                }
                rolesList.Add(roleItem);
                first = false;
            }
            return(rolesList);
        }
예제 #3
0
        /// <summary>
        /// Returns getbakeryName from bakjeryId
        /// </summary>
        /// <param name="bakeryId">int bakeryId</param>
        /// <returns>string bakeryName</returns>
        public string getBakeryName(int bakeryId)
        {
            string             bakeryName = bakeryId.ToString();
            AddRoleDataContext roles      = new AddRoleDataContext();

            //ReleName is bakeryId and Description is bakery name
            if (roles.aspnet_Roles.Single(p => p.RoleName == bakeryId.ToString()).Description.Length > 0)
            {
                bakeryName = roles.aspnet_Roles.Single(p => p.RoleName == bakeryId.ToString()).Description;
            }
            return(bakeryName);
        }