public void update(RoleViewModels item) { var it = bd.Roles.Find(item.Id); it.Name = item.Nom; bd.SaveChanges(); }
public void add(RoleViewModels rl) { IdentityRole r = new IdentityRole(); r.Id = rl.Id; r.Name = rl.Nom; bd.Roles.Add(r); bd.SaveChanges(); }
public RoleViewModels findid(string id) { var item = bd.Roles.Find(id); var u = new RoleViewModels { Id = item.Id, Nom = item.Name, }; return(u); }
public List <RoleViewModels> list() { var t = bd.Roles; List <RoleViewModels> tp = new List <RoleViewModels>(); foreach (var item in t) { var u = new RoleViewModels { Id = item.Id, Nom = item.Name }; tp.Add(u); } return(tp); }
public UserViewModel findroles(string id) { var query = bd.Users.Find(id); IEnumerable <IdentityUserRole> t = query.Roles; UserViewModel us = new UserViewModel(); us.Userid = query.Id; us.nomUser = query.UserName; us.Roles = new List <RoleViewModels>(); bd.SaveChanges(); RoleViewModels rl; foreach (var item in t) { rl = new RoleViewModels(); rl.Id = item.RoleId; rl.Nom = bd1.Roles.Find(item.RoleId).Name; us.Roles.Add(rl); } bd1.SaveChanges(); return(us); }
public ActionResult Edit(RoleViewModels c) { bd.update(c); return RedirectToAction("index"); }
public ActionResult Create(RoleViewModels c) { bd.add(c); return RedirectToAction("index"); }