Esempio n. 1
0
        protected void RadButtonCreate_Click(object sender, EventArgs e)
        {
            DALPortalDataContext dc = new DALPortalDataContext();
            string username = (string)Session["username"];
            string name = (string)Session["name"];

            string[] items = new string[RadListBoxDestination.Items.Count];

            for (int i = 0; RadListBoxDestination.Items.Count > i; i++) //RadListBoxItem item in RadListBoxDestination.Items)
            {
                items[i] = RadListBoxDestination.Items[i].Value;
            }

            Guid userId2 = dc.Users.Where(c => c.UserName.Equals(username)).Select(c => c.UserId).SingleOrDefault();
            List<userRole> roles = dc.userRoles.Where(c => c.userId.Equals(userId2)).ToList();

            for (int i = 0; roles.Count() > i; i++)
            {
                if (!items.Contains(roles[i].roleCode))
                {
                    //   roles.RemoveAt(i);
                    dc.userRoles.DeleteOnSubmit(roles[i]);
                }
            }

            for (int i = 0; items.Count() > i; i++)
            {
                if (!roles.Any(c => c.roleCode.Equals(items[i])))
                {
                    userRole roleUser = new userRole { userId = userId2, roleCode = items[i] };
                    dc.userRoles.InsertOnSubmit(roleUser);
                }
            }

            userSetting userSetting = dc.userSettings.Where(c => c.userId.Equals(userId2)).SingleOrDefault();

            if (userSetting == null)
            {
                userSetting = new userSetting { userId = userId2 };
                userSetting.companyCode = "ZW";
                userSetting.defaultCultureCode = "nl";
                userSetting.name = TextBoxName.Text;
                userSetting.siteAdmin = adminCheckBox.Checked;
                dc.userSettings.InsertOnSubmit(userSetting);
            }
            else
            {
                userSetting.siteAdmin = adminCheckBox.Checked;
                userSetting.name = TextBoxName.Text;
                userSetting.companyCode = companyDDL.SelectedValue;
            }

            dc.SubmitChanges();
            Response.Redirect("~/Pages/UserAccounts.aspx");
        }
Esempio n. 2
0
 partial void DeleteuserRole(userRole instance);
Esempio n. 3
0
 partial void UpdateuserRole(userRole instance);
Esempio n. 4
0
 partial void InsertuserRole(userRole instance);
Esempio n. 5
0
		private void detach_userRoles(userRole entity)
		{
			this.SendPropertyChanging();
			entity.applicationRole = null;
		}
Esempio n. 6
0
		private void detach_userRoles(userRole entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
Esempio n. 7
0
		private void attach_userRoles(userRole entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}