Exemple #1
0
 public List <Human> GetAll()
 {
     using (ClassifierEntities db = new ClassifierEntities())
     {
         return(db.Humans.ToList());
     }
 }
Exemple #2
0
 public string Insert(Human human)
 {
     try
     {
         ClassifierEntities db = new ClassifierEntities();
         db.Humans.Add(human);
         db.SaveChanges();
         return(human.ID + "was successfully inserted");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
Exemple #3
0
        public string DeleteAll()
        {
            try
            {
                ClassifierEntities db = new ClassifierEntities();
                db.Humans.RemoveRange(db.Humans);
                db.SaveChanges();

                return("All items were successfully deleted");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
Exemple #4
0
 public Human GetByID(int id)
 {
     try
     {
         using (ClassifierEntities se = new ClassifierEntities())
         {
             Human human = se.Humans.Find(id);
             return(human);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #5
0
        public string Delete(int id)
        {
            try
            {
                ClassifierEntities db = new ClassifierEntities();
                Human h = db.Humans.Find(id);

                db.Humans.Attach(h);
                db.Humans.Remove(h);
                db.SaveChanges();

                return(h.ID + "was successfully deleted");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
Exemple #6
0
        public string Update(int id, Human human)
        {
            try
            {
                ClassifierEntities db = new ClassifierEntities();
                Human h = db.Humans.Find(id);

                h.HOG     = human.HOG;
                h.IsHuman = human.IsHuman;

                db.SaveChanges();
                return(human.ID + "was successfully updated");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }