コード例 #1
0
 //adding category
 public void AddCategory(workout_category item)
 {
     try
     {
         CasestudyEntities db = new CasestudyEntities();
         db.workout_category.Add(item);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        //Editing category
        public void EditCategory(workout_category item)
        {
            try
            {
                CasestudyEntities db = new CasestudyEntities();
                var ObjCategory      = (from obj in db.workout_category
                                        where obj.category_id == item.category_id
                                        select obj).First();

                ObjCategory.category_name = item.category_name;

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        //Deleting category
        public void DeleteCategory(int id)
        {
            Console.WriteLine("enter the category id to delete");
            int Id = int.Parse(Console.ReadLine());

            try
            {
                CasestudyEntities db = new CasestudyEntities();
                var ObjCategory      = (from obj in db.workout_category
                                        where obj.category_id == Id
                                        select obj).First();
                db.workout_category.Remove(ObjCategory);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }