public bool AddStartWorkOut(Workout_Active model)
 {
     try
     {
         if (model.Id > 0)
         {
             Workout_Active editworkoutactive = db.WorkOutsActive.Where(a => a.Id == model.Id && a.WorkOutId == model.WorkOutId).FirstOrDefault();
             if (editworkoutactive != null)
             {
                 model.Start_Date = editworkoutactive.Start_Date;
                 model.Start_Time = editworkoutactive.Start_Time;
                 db.Entry(editworkoutactive).CurrentValues.SetValues(model);
             }
         }
         else
         {
             db.WorkOutsActive.Add(model);
         }
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #2
0
        public bool Update(WorkOut model)
        {
            try
            {
                WorkOut editWorkout = db.WorkOutCollection.Find(model.WorkOutId);
                if (editWorkout != null)
                {
                    editWorkout.WorkOutTitle = model.WorkOutTitle;
                    editWorkout.WorkOutNote  = model.WorkOutNote;
                    editWorkout.CategoryId   = model.CategoryId;
                    model.Updated            = DateTime.Now;
                    db.Entry(editWorkout).CurrentValues.SetValues(model);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public bool Add(Category model)
 {
     try
     {
         if (model.CategoryId > 0)
         {
             model.Updated = DateTime.Now;
             Category editCategory = db.Categories.Find(model.CategoryId);
             db.Entry(editCategory).CurrentValues.SetValues(model);
         }
         else
         {
             model.Created = DateTime.Now;
             db.Categories.Add(model);
         }
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }