public ActionResult Index(Client personne, string returnUrl) { Client perso = null; var Authentifie = HttpContext.User.Identity.IsAuthenticated; var test = HttpContext.User.Identity.Name; ViewData["Authentifie"] = Authentifie; if (ModelState.IsValid) { using (var db = new DariContext()) { perso = (from p in db.Clients where p.Prenom.Equals(personne.Prenom) && p.Password.Equals(personne.Password) select p).FirstOrDefault(); if (perso != null) { FormsAuthentication.SetAuthCookie(perso.Nom.ToString(), false); Authentifie = HttpContext.User.Identity.IsAuthenticated; if (!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } return(Redirect("/")); } } } return(View(personne)); }
public override string[] GetRolesForUser(string nom) { using (var db = new DariContext()) { var personne = db.Clients.SingleOrDefault(u => u.Nom == nom); if (personne == null) { return new string[] { } } ; return(personne.Roles == null ? new string[] { } : personne.Roles.Select(u => u.Title).ToArray()); } }
public ActionResult Inscription(Client client) { if (ModelState.IsValid) { using (var db = new DariContext()) { db.Clients.Add(client); db.SaveChanges(); } FormsAuthentication.SetAuthCookie(client.Nom.ToString(), false); return(Redirect("/Login/Index")); } return(View(client)); }
public override bool IsUserInRole(string nom, string title) { using (var db = new DariContext()) { var personne = db.Clients.SingleOrDefault(u => u.Nom == nom); if (personne == null) { return(false); } var role = (from r in db.Roles where r.Title.Equals(title) && r.Clients.Any(u => u.Nom == nom) select r).First(); return(role != null); } }
public ActionResult Index() { var Authentifie = HttpContext.User.Identity.IsAuthenticated; ViewData["Authentifie"] = Authentifie; Client personne = null; if (Authentifie) { using (var db = new DariContext()) { personne = (from p in db.Clients where p.Nom == HttpContext.User.Identity.Name select p).FirstOrDefault(); } } return(View(personne)); }
public override string[] GetAllRoles() { using (var db = new DariContext()) { return(db.Roles.Select(r => r.Title).ToArray()); } }
public DataBaseFactory() { ctxt = new DariContext(); }
public Repository(IDataBaseFactory dbFactory) { ctxt = dbFactory.Ctxt; dbSet = ctxt.Set <T>(); }