예제 #1
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);
     }
 }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }
예제 #4
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);
            }
        }