Ejemplo n.º 1
0
 public List <workout_category> ListAllCategory()
 {
     try
     {
         WorkoutAppEntities db = new WorkoutAppEntities();
         return(db.workout_category.ToList());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public List <workout_collection> ListAllCollection()
 {
     try
     {
         WorkoutAppEntities db = new WorkoutAppEntities();
         return(db.workout_collection.ToList());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
 //AddCategory
 public void AddCategory(workout_category item)
 {
     try
     {
         WorkoutAppEntities db = new WorkoutAppEntities();
         db.workout_category.Add(item);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
 public void AddCollection(workout_collection item)
 {
     try
     {
         WorkoutAppEntities db = new WorkoutAppEntities();
         db.workout_collection.Add(item);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 5
0
        public workout_category Get(int id)
        {
            workout_category objWork = null;

            try
            {
                WorkoutAppEntities db = new WorkoutAppEntities();
                objWork = (from obj in db.workout_category
                           where obj.category_id == id
                           select obj).First();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(objWork);
        }
Ejemplo n.º 6
0
        public void EditCategory(workout_category item)
        {
            try
            {
                WorkoutAppEntities db = new WorkoutAppEntities();
                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;
            }
        }
Ejemplo n.º 7
0
        //DeleteCategory
        public void DeleteCategory(int id)
        {
            Console.WriteLine("enter the category id to delete");
            int Id = int.Parse(Console.ReadLine());

            try
            {
                WorkoutAppEntities db = new WorkoutAppEntities();
                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;
            }
        }
Ejemplo n.º 8
0
        public void EditCategory(workout_collection item)
        {
            try
            {
                WorkoutAppEntities db = new WorkoutAppEntities();
                var ObjCategory       = (from obj in db.workout_collection
                                         where obj.workout_id == item.workout_id
                                         select obj).First();

                ObjCategory.workout_title         = item.workout_title;
                ObjCategory.workout_note          = item.workout_note;
                ObjCategory.calories_burn_per_min = item.calories_burn_per_min;
                ObjCategory.category_id           = item.category_id;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }