public ActionResult agregarol(string idu, string[] rol) { try { Guid idus = new Guid(idu); coneccionDataContext db = new coneccionDataContext(); foreach (string a in rol) { Guid id = new Guid(a); var x = db.UsersInRoles.Where(aa => aa.RoleId == id && aa.UserId == idus); if (x.Count() == 0) { UsersInRoles roles = new UsersInRoles() { UserId = idus, RoleId = id }; db.UsersInRoles.InsertOnSubmit(roles); db.SubmitChanges(); } } ViewBag.nombre = db.Users.Where(ss=>ss.UserId==idus).First().UserName; var rol_ = db.UsersInRoles.Where(b => b.UserId == idus). Select(b => new RolView() { id = b.Roles.RoleId, nombre = b.Roles.RoleName }).ToList(); return View(rol_); } catch (Exception) { return Content("false"); } }
public void agregarrolcliente(string a) { coneccionDataContext ob = new coneccionDataContext(); Guid idcli = ob.Users.Where(ss => ss.UserName == a).First().UserId; Guid irol = ob.Roles.Where(ss => ss.RoleName == "cliente").First().RoleId; UsersInRoles p = new UsersInRoles(); p.RoleId = irol; p.UserId = idcli; ob.UsersInRoles.InsertOnSubmit(p); ob.SubmitChanges(); }
public void agregarroldecliente(Guid a) { coneccionDataContext ob = new coneccionDataContext(); Guid irol = ob.Roles.Where(ss => ss.RoleName == "activado").First().RoleId; UsersInRoles p = new UsersInRoles(); p.RoleId = irol; p.UserId = a; ob.UsersInRoles.InsertOnSubmit(p); ob.SubmitChanges(); //db.Users.Where(ss => ss.UserId == idus).First().UserName; }
partial void DeleteUsersInRoles(UsersInRoles instance);
partial void UpdateUsersInRoles(UsersInRoles instance);
partial void InsertUsersInRoles(UsersInRoles instance);
private void detach_UsersInRoles(UsersInRoles entity) { this.SendPropertyChanging(); entity.Users = null; }
private void attach_UsersInRoles(UsersInRoles entity) { this.SendPropertyChanging(); entity.Users = this; }