Carrotware.CMS.Core.ExtendedUserData.AddToSite C# (CSharp) Method

AddToSite() public method

public AddToSite ( System.Guid siteID ) : bool
siteID System.Guid
return bool
        public bool AddToSite(Guid siteID)
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_UserSiteMapping map = (from m in _db.carrot_UserSiteMappings
                                              where m.UserId == this.UserId
                                                && m.SiteID == siteID
                                              select m).FirstOrDefault();

                if (map == null) {
                    _siteIDs = null;

                    map = new carrot_UserSiteMapping();
                    map.UserSiteMappingID = Guid.NewGuid();
                    map.SiteID = siteID;
                    map.UserId = this.UserId;

                    _db.carrot_UserSiteMappings.InsertOnSubmit(map);
                    _db.SubmitChanges();

                    return true;
                } else {
                    return false;
                }
            }
        }

Usage Example

コード例 #1
0
		protected void btnAddUsers_Click(object sender, EventArgs e) {
			if (!String.IsNullOrEmpty(hdnUserID.Value)) {
				ExtendedUserData exUsr = new ExtendedUserData(hdnUserID.Value);
				exUsr.AddToSite(guidSiteID);

				if (chkAddToEditor.Checked) {
					exUsr.AddToRole(SecurityData.CMSGroup_Editors);
				}
			}

			Response.Redirect(SiteData.CurrentScriptName + "?id=" + guidSiteID.ToString());
		}
All Usage Examples Of Carrotware.CMS.Core.ExtendedUserData::AddToSite