public List<TatooineModel.Citizens> GetAllCitizens()
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         return db.Citizens.Include("Roles").Include("Status").ToList();
     }
 }
 public List<TatooineModel.Roles> GetRoles()
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         return db.Roles.ToList();
     }
 }
 public List<TatooineModel.Statuses> GeStatus()
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         return db.Status.ToList();
     }
 }
 public TatooineModel.Roles GetRol(string Id)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         int id = int.Parse(Id);
         return db.Roles.SingleOrDefault(p => p.Id == id);
     }
 }
 public TatooineModel.Citizens GetCitizen(string CitizenID)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         long Id = long.Parse(CitizenID);
         return db.Citizens.SingleOrDefault(p => p.Id == Id);
     }
 }
 public List<TatooineModel.Citizens> CitizensInRole(string Id)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         int id = int.Parse(Id);
         return db.Citizens.Where(p => p.IdRole == id).ToList();
     }
 }
 public int AddRole(TatooineModel.Roles Rol)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         db.Roles.Add(Rol);
         db.SaveChanges();
         return Rol.Id;
     }
 }
 public long AddCitizen(TatooineModel.Citizens Citizen)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         db.Citizens.Add(Citizen);
         db.SaveChanges();
         return Citizen.Id;
     }
 }
 public bool DeleteCitizen(string CitizenID)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         var Citizen = db.Citizens.SingleOrDefault(p => p.Id == long.Parse(CitizenID));
         db.Citizens.Remove(Citizen);
         db.SaveChanges();
         return true;
     }
 }
 public bool UpdateRole(TatooineModel.Roles Rol)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         var RolBD = db.Roles.SingleOrDefault(p => p.Id == Rol.Id);
         RolBD.RoleName = Rol.RoleName;
         RolBD.ParentId = Rol.ParentId;
         db.SaveChanges();
         return true;
     }
 }
 public bool DeleteRole(string Id)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         int id = int.Parse(Id);
         var Rol = db.Roles.SingleOrDefault(p => p.Id == id);
         db.Roles.Remove(Rol);
         db.SaveChanges();
         return true;
     }
 }
 public bool UpdateCitizen(TatooineModel.Citizens Citizen)
 {
     using (var db = new TatooineCitizensRegistryEntities())
     {
         var CitizenDB = db.Citizens.SingleOrDefault(p => p.Id == Citizen.Id);
         CitizenDB.Name = Citizen.Name;
         CitizenDB.Specie = Citizen.Specie;
         CitizenDB.IdRole = Citizen.IdRole;
         CitizenDB.IdStatus = Citizen.IdStatus;
         db.SaveChanges();
         return true;
     }
 }