public async Task <IActionResult> GetMetrics()
        {
            var user = await _jwtService.CheckUser(Request.Cookies["JWT"]);

            if (user == null)
            {
                return(Unauthorized());
            }

            return(Json(_userMetricsManager.GetUserMetrics(user)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetTonnage(Statistics stats)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }
            var user = await _jwtService.CheckUser(Request.Cookies["JWT"]);

            if (user == null)
            {
                return(Unauthorized());
            }

            return(await _statisticsManager.GetTonnage(stats));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <TrainingPlan> > Post([FromForm] TrainingPlan plan)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }
            var user = await _jwtService.CheckUser(Request.Cookies["JWT"]);

            if (user == null)
            {
                return(Unauthorized());
            }

            return(await _trainingPlanManager.AddPlan(plan));
        }
        public async Task <ActionResult> Post([FromForm] Excercise excercise)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }

            var user = await _jwtService.CheckUser(Request.Cookies["JWT"]);

            if (user == null)
            {
                return(Unauthorized());
            }

            return(await _excerciseManager.AddExcercise(excercise));
        }
        public async Task <ActionResult <ICollection <ExcerciseInPlan> > > GetPreSsestion(int Id, int Day)
        {
            var user = await _jwtService.CheckUser(Request.Cookies["JWT"]);

            if (user == null)
            {
                return(Unauthorized());
            }
            var plan = await _context.TrainingPlans.FindAsync(Id);

            if (plan != null)
            {
                var userExser = await _context.ExcercisesInPlan.Include(c => c.Excercise).Include(c => c.Excercise.AssistantMuscle).Include(c => c.Excercise.TargetMuscle).Where(p => p.PlanId == Id && p.Day == Day).Include(c => c.MuscleGroup).ToListAsync();

                if (userExser.Count != 0)
                {
                    return(Json(await _sessionManager.GetPlanByIdAndDay(Id, Day, userExser)));
                }
                return(NoContent());
            }

            return(NoContent());
        }
        public async Task <ActionResult> EndTraining(EndTrainingViewModel trainingSubmit)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }
            var user = await _jwtService.CheckUser(Request.Cookies["JWT"]);

            if (user == null)
            {
                return(Unauthorized());
            }


            return(await _trainingManager.SubmitTraining(user, trainingSubmit));;
        }