Beispiel #1
0
 public String Login(user login)
 {
     using (Database1Entities6 us = new Database1Entities6())
     {
         var lusername = us.users.Where(a => a.username == login.username).FirstOrDefault();
         var lpassword = us.users.Where(a => a.passwords == login.passwords).FirstOrDefault();
         if (lusername != null && lpassword != null)
         {
             return(JwtManager.GenerateToken(lusername.name, lusername.username, lusername.roles));
         }
         else
         {
             return("false");
         }
     }
 }
Beispiel #2
0
 //sending services
 public JsonResult Get(string token)
 {
     using (Database1Entities6 us = new Database1Entities6())
     {
         List <servicess> list;
         if (JwtManager.ValidateToken(token).Equals("developer"))
         {
             list = us.servicesses.Where(a => (a.parent.Equals("itpart") && a.accesslevel.Equals("1")) || (a.parent.Equals("general")) || (a.parent.Equals("entpart"))).ToList();
             var jsondata = Json(list, JsonRequestBehavior.AllowGet);
             return(jsondata);
         }
         else if (JwtManager.ValidateToken(token).Equals("manager"))
         {
             list = us.servicesses.Where(a => (a.parent.Equals("itpart") && a.accesslevel.Equals("3")) || (a.parent.Equals("general")) || (a.parent.Equals("entpart"))).ToList();
             var jsondata = Json(list, JsonRequestBehavior.AllowGet);
             return(jsondata);
         }
         else if (JwtManager.ValidateToken(token).Equals("seniDev"))
         {
             list = us.servicesses.Where(a => (a.parent.Equals("itpart") && a.accesslevel.Equals("2")) || (a.parent.Equals("general")) || (a.parent.Equals("entpart"))).ToList();
             var jsondata = Json(list, JsonRequestBehavior.AllowGet);
             return(jsondata);
         }
         else if (JwtManager.ValidateToken(token).Equals("trainer"))
         {
             list = us.servicesses.Where(a => (a.parent.Equals("trainingpart") && a.accesslevel.Equals("1")) || (a.parent.Equals("general")) || (a.parent.Equals("entpart"))).ToList();
             var jsondata = Json(list, JsonRequestBehavior.AllowGet);
             return(jsondata);
         }
         else if (JwtManager.ValidateToken(token).Equals("seniDev"))
         {
             list = us.servicesses.Where(a => (a.parent.Equals("itpart") && a.accesslevel.Equals("1")) || (a.parent.Equals("general")) || (a.parent.Equals("entpart"))).ToList();
             var jsondata = Json(list, JsonRequestBehavior.AllowGet);
             return(jsondata);
         }
         else if (JwtManager.ValidateToken(token).Equals("receptionist"))
         {
             list = us.servicesses.Where(a => (a.parent.Equals("receppart") && a.accesslevel.Equals("1")) || (a.parent.Equals("general")) || (a.parent.Equals("entpart"))).ToList();
             var jsondata = Json(list, JsonRequestBehavior.AllowGet);
             return(jsondata);
         }
     }
     return(null);
 }