public User ClearRolesByUser(User user)
 {
     using (var context = new AirTrackContext()) {
         context.SaveChanges();
         return(user);
     }
 }
 public Role GetRoleByName(string name)
 {
     using (var context = new AirTrackContext())
     {
         return(context.Roles.Where(x => x.Name.Equals(name)).FirstOrDefault());
     }
 }
 public Role GetById(int Id)
 {
     using (var context = new AirTrackContext())
     {
         return(context.Roles.Find(Id));
     }
 }
 public List <Role> GetAll()
 {
     using (var context = new AirTrackContext())
     {
         return(context.Roles.ToList());
     }
 }
Exemple #5
0
 public List <User> GetUsersRole(string roleName)
 {
     using (var context = new AirTrackContext())
     {
         var users = context.Users.Include(u => u.Roles).ToList();
         return(users);
     }
 }
Exemple #6
0
 public User GetById(int Id)
 {
     using (var context = new AirTrackContext())
     {
         // var user = context.Users.Include(x => x.Roles).Where(x=>x.Id == Id).FirstOrDefault();
         return(context.Users.Find());
     }
 }
Exemple #7
0
 public List <User> GetAll()
 {
     using (var context = new AirTrackContext())
     {
         var users = context.Users.Include(x => x.Roles).ToList <User>();
         context.SaveChanges();
         return(users);
     }
 }
Exemple #8
0
 public void Delete(int Id)
 {
     using (var context = new AirTrackContext())
     {
         var user = GetById(Id);
         context.Users.Remove(user);
         context.SaveChanges();
     }
 }
Exemple #9
0
 public User Create(User user)
 {
     using (var context = new AirTrackContext())
     {
         context.Users.Add(user);
         context.SaveChanges();
         return(user);
     }
 }
 public Role Update(Role role)
 {
     using (var context = new AirTrackContext())
     {
         context.Roles.Update(role);
         context.SaveChanges();
         return(role);
     }
 }
 public void Delete(int Id)
 {
     using (var context = new AirTrackContext())
     {
         var role = GetById(Id);
         context.Roles.Remove(role);
         context.SaveChanges();
     }
 }