Пример #1
0
 public void AddCategory(workout_Category item)
 {
     try
     {
         WorkoutDbEntities2 db = new WorkoutDbEntities2();
         db.workout_Category.Add(item);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        public workout_Category GetCategory(int id)
        {
            workout_Category objWork = null;

            try
            {
                WorkoutDbEntities2 db = new WorkoutDbEntities2();
                objWork = (from obj in db.workout_Category
                           where obj.category_id == id
                           select obj).First();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(objWork);
        }
Пример #3
0
        public void EditCategory(workout_Category item)
        {
            try
            {
                WorkoutDbEntities2 db = new WorkoutDbEntities2();
                var ObjCategory       = (from obj in db.workout_Category
                                         where obj.category_id == item.category_id
                                         select obj).First();

                ObjCategory.Name = item.Name;

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public void DeleteCategory(int id)
        {
            Console.WriteLine("enter the category id to delete");
            int Id = int.Parse(Console.ReadLine());

            try
            {
                WorkoutDbEntities2 db = new WorkoutDbEntities2();
                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;
            }
        }