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;
}
}
}
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()); }