Пример #1
0
        private async void WorkoutPlanListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            WorkoutPlan workoutPlan = new WorkoutPlan((WorkoutPlanViewModel)e.SelectedItem);

            var editPlanPage = new EditWorkoutPlan(workoutPlan, currentTrainer);
            await Navigation.PushAsync(editPlanPage);
        }
Пример #2
0
        private async Task <WorkoutPlan> GenerateShortPlan(GenerateWorkoutPlanInputModel inputModel)
        {
            var workoutPlan = new WorkoutPlan()
            {
                ExpireDate = DateTime.UtcNow.AddDays(inputModel.DurationInDays),
                DaysInWeek = inputModel.WeekdaysCount,
                UserId     = inputModel.UserId,
            };

            switch (inputModel.Experience)
            {
            case Experience.Beginner:
                workoutPlan.Difficulty = Difficulty.Easy;
                break;

            case Experience.Intermediate:
                workoutPlan.Difficulty = Difficulty.Medium;
                break;

            case Experience.Advanced:
                workoutPlan.Difficulty = Difficulty.Hard;
                break;
            }

            for (int i = 0; i < inputModel.WeekdaysCount; i++)
            {
                TrainingDay trainingDay = await this.GenerateFullBodyDay(inputModel.Goal, workoutPlan.Difficulty, workoutPlan);

                workoutPlan.TrainingDays.Add(trainingDay);
            }

            return(workoutPlan);
        }
 public IActionResult Update(int id, [Bind("Id,Name,Description")] WorkoutPlan workoutPlan)
 {
     workoutPlan.UserEmail = User.Identity.Name;
     _unitOfWork.WorkoutPlanRepository.Update(workoutPlan);
     _unitOfWork.Save();
     return(RedirectToAction("Index"));
 }
Пример #4
0
        public void PrintWorkoutPlan(WorkoutPlan workoutPlan)
        {
            Document document = new Document(PageSize.A4);

            System.IO.MemoryStream msReport = new System.IO.MemoryStream();  // for asp.net

            try
            {
                PdfWriter writer = PdfWriter.GetInstance(document, msReport);
                document.Open();

                PdfContentByte cb = writer.DirectContent;
                PrintFrame(document, cb, workoutPlan);
                PrintContent(document, cb, workoutPlan);
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            document.Close();

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("content-disposition", "inline;filename=Export.pdf"); //use inline if want to open in browser itself, else attachment to save it.
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.BinaryWrite(msReport.ToArray());
            HttpContext.Current.Response.End();
        }
Пример #5
0
        public WorkoutPlan getWorkPlanDetails(int id)
        {
            SwimWorkoutDBContext swimDb = new SwimWorkoutDBContext();
            WorkoutPlan          woplan = swimDb.getWorkOutPlan(id);

            return(woplan);
        }
        public IActionResult OnPost(int? ClientId)
        {
            if (!ClientId.HasValue)
            {
                return RedirectToPage("/Index");
            }

            BFS requestDirector = new BFS();
            Client = requestDirector.GetClientById(ClientId.Value);
            ActiveWorkoutPlans = requestDirector.GetActiveWorkoutPlansByClientId(Client.ClientId);
            InactiveWorkoutPlans = requestDirector.GetInactiveWorkoutPlansByClientId(Client.ClientId);

            if (Submit.Equals("SubmitStartWorkout"))
            {
                Workout inProgressWorkout = requestDirector.GetInProgressWorkoutByClientId(Client.ClientId);
                if (inProgressWorkout.WorkoutName == null)
                {
                    WorkoutPlan workoutPlan = requestDirector.GetWorkoutPlanById(WorkoutPlanId);
                    int workoutId = requestDirector.StartWorkout(workoutPlan);
                }
                else
                {
                    ErrorString = "You already have a workout in progress";
                }
                
            }

            return Page();
        }
        private WorkoutPlan CreatePlanForExecutedWorkout(ExecutedWorkout lastExecutedWorkout)
        {
            var workoutPlan        = new WorkoutPlan(lastExecutedWorkout.Workout, true);
            var exercisesInWorkout = lastExecutedWorkout.Workout.Exercises.ToList();
            var userSettings       = GetUserSettings(lastExecutedWorkout.Workout.CreatedByUserId);

            for (short x = 0; x < exercisesInWorkout.Count; x++)
            {
                var exerciseInWorkout = exercisesInWorkout[x];

                //Find the ExercisePlan object from our new WorkoutPlan object for this exercise
                var exercisePlan = workoutPlan.Exercises.First(x => x.Sequence == exerciseInWorkout.Sequence);

                //Get the ExecutedExercises for this exercise from the last time this workout
                //was performed
                var exercisesFromLastTime =
                    lastExecutedWorkout
                    .Exercises
                    .Where(x => x.ExerciseId == exerciseInWorkout.ExerciseId);

                exercisePlan.SetLastTimeValues(exercisesFromLastTime);

                //If recommendations are enabled, apply them
                if (userSettings != null && userSettings.RecommendationsEnabled)
                {
                    var recommendation =
                        _recommendationService.GetRecommendation(
                            exerciseInWorkout.Exercise, lastExecutedWorkout, userSettings);

                    exercisePlan.ApplyRecommendation(recommendation);
                }
            }

            return(workoutPlan);
        }
Пример #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] WorkoutPlan workoutPlan)
        {
            if (id != workoutPlan.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workoutPlan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkoutPlanExists(workoutPlan.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(workoutPlan));
        }
Пример #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            WorkoutPlan workoutPlan = db.WorkoutPlans.Find(id);

            db.WorkoutPlans.Remove(workoutPlan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #10
0
        public EditWorkoutPlan(WorkoutPlan workoutPlan, Trainer trainer)
        {
            InitializeComponent();
            cWorkoutPlan = workoutPlan;
            cTrainer     = trainer;

            workoutPlanWorkouts.ItemSelected += WorkoutPlanWorkouts_ItemSelected;
        }
Пример #11
0
        public ActionResult ViewWorkOutPlan(int id)
        {
            WorkOutPlan_BLL workoutbll = new WorkOutPlan_BLL();

            WorkoutPlan wp = workoutbll.getWorkPlanDetails(id);

            return(View(wp));
        }
Пример #12
0
        public JsonResult Update([FromBody] WorkoutPlan workoutPlan)
        {
            var context = new WorkoutTrackerContext();

            workoutPlan.UserId = this.UserId;
            context.Entry(context.WorkoutPlans.Find(workoutPlan.Id)).CurrentValues.SetValues(workoutPlan);
            context.SaveChanges();
            return(Json(workoutPlan));
        }
Пример #13
0
        public JsonResult Create([FromBody] WorkoutPlan workoutPlan)
        {
            var context = new WorkoutTrackerContext();

            workoutPlan.UserId = this.UserId;
            context.WorkoutPlans.Add(workoutPlan);
            context.SaveChanges();
            return(Json(workoutPlan));
        }
Пример #14
0
        public ExecutedWorkout Create(WorkoutPlan plan, DateTime startDateTime, DateTime endDateTime)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }

            return(CreateFromPlan(plan, startDateTime, endDateTime));
        }
Пример #15
0
        public ActionResult EditWorkoutPlan(int planId)
        {
            WorkOutPlan_BLL workoutbll  = new WorkOutPlan_BLL();
            WorkoutPlan     workoutPlan = workoutbll.getWorkPlanDetails(planId);

            Session["WorkoutSetList"] = workoutPlan.WorkoutSet;
            Session["WorkoutPlanId"]  = planId;
            return(View(workoutPlan));
        }
Пример #16
0
        public ActionResult CreatePlan(WorkoutPlan workoutPlan)
        {
            _context.WorkoutPlans.Add(workoutPlan);
            _context.SaveChanges();



            return(RedirectToAction("NewWorkout", "Workouts"));
        }
        public async Task <IActionResult> Create()
        {
            WorkoutPlan newPlan = new WorkoutPlan()
            {
                Name = "Workout Plan"
            };

            return(View("/Views/Workout/edit.cshtml", newPlan));
        }
Пример #18
0
 public IActionResult CreateNewWorkout([Bind("Name , CategoryName")] WorkoutPlan workoutPlan)
 {
     if (workoutPlan.Name == null || workoutPlan.CategoryName == null)
     {
         return(View("AddWorkout"));
     }
     workoutPlan.CreatorName = User.Identity.Name;
     workoutPlanLogic.AddWorkoutPlan(workoutPlan);
     return(RedirectToAction("ShowYourWorkouts"));
 }
Пример #19
0
        public static void SuggestWorkout(string userID)
        {
            /// Is it first
            WorkoutPlan wp = new WorkoutPlan();
            var         v  = wp.GetLastWorkoutsByUserId(userID);

            if (v.Count() == 0)
            {
                // Some 1RM suggestions
            }
        }
Пример #20
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] WorkoutPlan workoutPlan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(workoutPlan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(workoutPlan));
        }
Пример #21
0
 private ActionResult <int> CreateWorkoutFromWorkoutPlanForPast(WorkoutPlan plan, DateTime startDateTime, DateTime endDateTime)
 {
     try
     {
         var executedWorkout = _executedWorkoutService.Create(plan, startDateTime, endDateTime);
         return(Ok(executedWorkout.Id));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
Пример #22
0
 private ActionResult <int> CreateWorkoutFromWorkoutPlan(WorkoutPlan plan, bool startWorkout)
 {
     try
     {
         var executedWorkout = _executedWorkoutService.Create(plan, startWorkout);
         return(Ok(executedWorkout.Id));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
Пример #23
0
 public ActionResult Edit([Bind(Include = "WorkoutPlanID,WorkoutID,PlanID,Repetition,WorkoutPlanSet,Rest,WorkoutPlanWeight")] WorkoutPlan workoutPlan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(workoutPlan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlanID    = new SelectList(db.Plans, "PlanID", "UserID", workoutPlan.PlanID);
     ViewBag.WorkoutID = new SelectList(db.Workouts, "WorkoutID", "Name", workoutPlan.WorkoutID);
     return(View(workoutPlan));
 }
Пример #24
0
        public ActionResult SaveWorkoutPlan()
        {
            WorkOutPlan_BLL plan_dll    = new WorkOutPlan_BLL();
            WorkoutPlan     workoutPlan = new WorkoutPlan();

            workoutPlan.WorkoutSet = Session["WorkoutSetList"] as List <WorkoutSet>;
            workoutPlan.Date       = Session["WorkoutPlanDate"] as String;
            plan_dll.insertWorkoutPlan(workoutPlan);
            Session["WorkoutSetList"] = null;


            return(JavaScript(String.Format("window.location = '{0}'", Url.Action("Index", "Home"))));
        }
Пример #25
0
        // GET: WorkoutPlans/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WorkoutPlan workoutPlan = db.WorkoutPlans.Find(id);

            if (workoutPlan == null)
            {
                return(HttpNotFound());
            }
            return(View(workoutPlan));
        }
        public IActionResult Create(string name, string description)
        {
            var workoutPlan = new WorkoutPlan
            {
                Name                = name,
                Description         = description,
                UserEmail           = User.Identity.Name,
                WorkoutPlanWorkouts = new List <WorkoutPlanWorkout>()
            };

            _unitOfWork.WorkoutPlanRepository.Insert(workoutPlan);
            _unitOfWork.Save();

            return(Content($"Workoutplan {name} was successfully added"));
        }
        public async Task <IActionResult> Session(long PlanID, int SessionIndex)
        {
            FitnessUser currentUser = await GetUser();

            WorkoutPlan plan = await dbContext.WorkoutPlans.FirstOrDefaultAsync(plan => plan.ID == PlanID && plan.User == currentUser);

            if (plan == null || SessionIndex < 0 || SessionIndex >= plan.Sessions.Length)
            {
                return(BadRequest());
            }

            WorkoutSession session = plan.Sessions[SessionIndex];

            return(View(session));
        }
Пример #28
0
        // Method to insert workout plan to DB
        public Boolean insertWorkoutPlan(WorkoutPlan plan)
        {
            SwimWorkoutDBContext swimDB = new SwimWorkoutDBContext();
            List <int>           setIds;

            // insert plan
            plan.ID = swimDB.insertWorkoutPlan(plan.Date);

            // insert sets
            setIds = insertWorkoutSets(plan.WorkoutSet);

            // insert plan members
            insertWorkoutPlanMembers(plan.ID, setIds);

            return(true);
        }
Пример #29
0
        public ExecutedWorkout Create(WorkoutPlan plan, bool startWorkout)
        {
            if (plan == null)
            {
                throw new ArgumentNullException(nameof(plan));
            }

            if (startWorkout)
            {
                return(CreateFromPlan(plan, plan.SubmittedDateTime, null));
            }
            else
            {
                return(CreateFromPlan(plan, null, null));
            }
        }
Пример #30
0
        // GET: WorkoutPlans/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WorkoutPlan workoutPlan = db.WorkoutPlans.Find(id);

            if (workoutPlan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PlanID    = new SelectList(db.Plans, "PlanID", "UserID", workoutPlan.PlanID);
            ViewBag.WorkoutID = new SelectList(db.Workouts, "WorkoutID", "Name", workoutPlan.WorkoutID);
            return(View(workoutPlan));
        }