public IHttpActionResult Put(WorkoutPlanEdit plan)
        {
            if (ModelState.IsValid)
            {
                var service = CreateWorkoutPlanService();

                if (service.UpdatePlan(plan))
                {
                    return(Ok());
                }

                return(InternalServerError());
            }
            return(BadRequest(ModelState));
        }
Example #2
0
        public bool UpdatePlan(WorkoutPlanEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .WorkoutPlans
                    .Single(e => e.PlanId == model.PlanId && e.CreatedBy == _userId.ToString());

                entity.PlanName    = model.PlanName;
                entity.Intensity   = model.Intensity;
                entity.ProgramType = (Data.WorkoutType)model.ProgramType;

                return(ctx.SaveChanges() == 1);
            }
        }