public static bool AddUserToRole(string UserName, string RoleName) { ICCData ctx = new ICCData(); var user = (from u in ctx.Users where string.Compare(u.Email, UserName, true) == 0 select u).FirstOrDefault(); var role = (from r in ctx.Roles where string.Compare(r.Name, RoleName, true) == 0 select r).FirstOrDefault(); if (user.Id > 0 && role.Id > 0) { var ur = new UserRole() { UserId = user.Id, RoleId = role.Id }; ctx.UserRoles.InsertOnSubmit(ur); ctx.SubmitChanges(); return true; } return false; }
private void detach_UserRoles(UserRole entity) { this.SendPropertyChanging(); entity.User = null; }
private void attach_UserRoles(UserRole entity) { this.SendPropertyChanging(); entity.User = this; }
partial void DeleteUserRole(UserRole instance);
partial void UpdateUserRole(UserRole instance);
partial void InsertUserRole(UserRole instance);