예제 #1
0
        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));
        }
예제 #2
0
 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()); }
 }
예제 #3
0
 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));
 }
예제 #4
0
 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);
     }
 }
예제 #5
0
        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));
        }
예제 #6
0
 public override string[] GetAllRoles()
 {
     using (var db = new DariContext()) { return(db.Roles.Select(r => r.Title).ToArray()); }
 }
예제 #7
0
 public DataBaseFactory()
 {
     ctxt = new DariContext();
 }
예제 #8
0
 public Repository(IDataBaseFactory dbFactory)
 {
     ctxt  = dbFactory.Ctxt;
     dbSet = ctxt.Set <T>();
 }