Пример #1
0
        public List<Groupe> LoadAll()
        {
            try
            {
                using (APIEntities manager = new APIEntities())
                {
                    return manager.Groupe.ToList();
                }
            }
            catch
            {

                return null;
            }
        }
Пример #2
0
 public bool Login(string login, string password, string apiKey)
 {
     try
     {
         using (APIEntities manager = new APIEntities())
         {
             User loggedUser = manager.User.Where(x => x.Login == login && x.Password == password && apiKey == Global.ApiKey).First();
             return loggedUser != null;
         }
     }
     catch
     {
         return false;
     }
 }
Пример #3
0
        public bool Delete(int Id)
        {
            try
            {
                using (APIEntities manager = new APIEntities())
                {
                    manager.Groupe.Remove(manager.Groupe.Where(x=>x.Id == Id).First());
                    manager.SaveChanges();
                    return true;
                }
            }
            catch
            {

                return false;
            }
        }
Пример #4
0
        public bool Add(Groupe group)
        {
            try
            {
                using (APIEntities manager = new APIEntities())
                {
                    manager.Groupe.Add(group);
                    manager.SaveChanges();
                    return true;
                }
            }
            catch
            {

                return false;
            }
        }
Пример #5
0
        public List<Groupe> LoadByField(string Field, string Value)
        {
            try
            {
                using (APIEntities manager = new APIEntities())
                {
                    switch (Field)
                    {
                        case "Nom":
                            return manager.Groupe.Where(x => x.Nom == Value).ToList();
                            break;
                        case "Description":
                            return manager.Groupe.Where(x => x.Description == Value).ToList();
                            break;
                        default:
                            return null;
                            break;
                    }

                }
            }
            catch
            {

                return null;
            }
        }
Пример #6
0
        public bool Update(Groupe groupe)
        {
            try
            {
                using (APIEntities manager = new APIEntities())
                {
                    Groupe groupeE = manager.Groupe.Where(x => x.Id == groupe.Id).First();
                    manager.Groupe.Attach(groupeE);
                    manager.Entry(groupeE).State = System.Data.Entity.EntityState.Modified;
                    manager.SaveChanges();
                    return true;
                }
            }
            catch
            {

                return false;
            }
        }
Пример #7
0
        public Groupe LoadByPrimaryKey(int GroupId)
        {
            try
            {
                using (APIEntities manager = new APIEntities())
                {
                    return manager.Groupe.Where(x => x.Id == GroupId).First();
                }
            }
            catch
            {

                return null;
            }
        }