public JsonResult addrol(string idUs2, string idRol) { //string data = idUs2 + idRol; Guid _idUs = new Guid(idUs2); Guid _idRol = new Guid(idRol); ConectorDataContext db = new ConectorDataContext(); UsersInRole rol = new UsersInRole() { RoleId = _idRol, UserId = _idUs }; int aa = db.UsersInRoles.Where(a => a.RoleId == _idRol && a.UserId == _idUs).Count(); if (aa == 1) { return Json(new { success = "Error Este Rol esta Asignado" }); } db.UsersInRoles.InsertOnSubmit(rol); db.SubmitChanges(); string nombrerol = db.Roles.Where(a => a.RoleId == _idRol).First().RoleName; return Json(new { success = "Rol Agregado", rol = nombrerol, idRol = _idRol, idUs = _idUs }); }
partial void DeleteUsersInRole(UsersInRole instance);
partial void UpdateUsersInRole(UsersInRole instance);
partial void InsertUsersInRole(UsersInRole instance);
private void detach_UsersInRoles(UsersInRole entity) { this.SendPropertyChanging(); entity.User = null; }
private void attach_UsersInRoles(UsersInRole entity) { this.SendPropertyChanging(); entity.User = this; }