예제 #1
0
 // Delete book
 public string DeleteHuman(string humanId)
 {
     if (!String.IsNullOrEmpty(humanId))
     {
         try
         {
             int _humanId = Int32.Parse(humanId);
             using (HumanDBContext contextObj = new HumanDBContext())
             {
                 var _human = contextObj.human.Find(_humanId);
                 contextObj.human.Remove(_human);
                 contextObj.SaveChanges();
                 return("Selected human record deleted sucessfully");
             }
         }
         catch (Exception)
         {
             return("Human details not found");
         }
     }
     else
     {
         return("Invalid operation");
     }
 }
예제 #2
0
        //Update Human
        public string UpdateHuman(Human human)
        {
            if (human != null)
            {
                using (HumanDBContext contextObj = new HumanDBContext())
                {
                    int   humanId = Convert.ToInt32(human.Id);
                    Human _human  = contextObj.human.Where(b => b.Id == humanId).FirstOrDefault();
                    _human.Name      = human.Name;
                    _human.Address   = human.Address;
                    _human.Age       = human.Age;
                    _human.Hair      = human.Hair;
                    _human.FileName  = human.FileName;
                    _human.Interests = human.Interests;


                    contextObj.SaveChanges();
                    return("Human record updated successfully");
                }
            }
            else
            {
                return("Invalid human record");
            }
        }
예제 #3
0
 // Add book
 public string AddHuman(Human human)
 {
     if (human != null)
     {
         using (HumanDBContext contextObj = new HumanDBContext())
         {
             contextObj.human.Add(human);
             contextObj.SaveChanges();
             return("Human record added successfully");
         }
     }
     else
     {
         return("Invalid Human record");
     }
 }