Esempio n. 1
0
        public async Task <IActionResult> SaveRepsBilateral(BilateralRepsVM convertedData)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            var userVM = new UserVM
            {
                UserId   = user.Id,
                UserName = user.UserName
            };


            History history = new History
            {
                ExerciseId = convertedData.ExerciseId,
                Date       = DateTime.Now,
                UserId     = userVM.UserId
            };

            await _repositoryWrapper.HistoryRepository.CreateAsync(history);


            BilateralExercisesHistory bilateralHistory = new BilateralExercisesHistory
            {
                ExerciseId    = convertedData.ExerciseId,
                UserId        = userVM.UserId,
                Date          = history.Date,
                LeftSideReps  = convertedData.LeftSideReps,
                RightSideReps = convertedData.RightSideReps
            };

            await _repositoryWrapper.BilateralExercisesHistoryRepository.CreateAsync(bilateralHistory);


            return(Ok());
        }
        public async Task <ResultVM> SaveRepsBilateral(object reps)
        {
            try
            {
                var     model   = JsonConvert.DeserializeObject <BilateralExercisesHistoryVM>(reps.ToString());
                History history = new History
                {
                    ExerciseId = model.ExerciseId,
                    Date       = DateTime.Now,
                    UserId     = model.UserId
                };

                await _repositoryWrapper.HistoryRepository.CreateAsync(history);

                BilateralExercisesHistory bilateralHistory = new BilateralExercisesHistory
                {
                    ExerciseId    = model.ExerciseId,
                    UserId        = model.UserId,
                    LeftSideReps  = model.LeftSideReps,
                    RightSideReps = model.RightSideReps
                };

                await _repositoryWrapper.BilateralExercisesHistoryRepository.CreateAsync(bilateralHistory);
            }
            catch (Exception ex)
            {
                return(new ResultVM
                {
                    Status = Status.Error,
                    Message = ex.Message
                });
            }

            return(new ResultVM
            {
                Status = Status.Success,
                Message = "Numărul de repetări a fost memorat în Baza de Date"
            });
        }