Пример #1
0
 public async Task <bool> LogWorkout(ApplicationUser user, LoggedWorkout model)
 {
     model.Id     = Guid.NewGuid().ToString();
     model.UserId = user.Id;
     model.Date   = DateTime.Now;
     _context.LoggedWorkouts.Add(model);
     return(await saveAsync(1));
 }
Пример #2
0
        public async Task <IActionResult> LogWorkout(string Id, string[] RepsCompleted, string[] Weight, string[] Notes)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {   // make them login
                return(Challenge());
            }
            var workout = await _workoutService.getWorkout(Id);

            if (currentUser.Id == workout.UserId || null == workout.UserId)
            {
                LoggedWorkout model = new LoggedWorkout();
                model.WorkoutName   = workout.Name;
                model.WorkoutId     = Id;
                model.RepsCompleted = RepsCompleted;
                model.Weight        = Weight;
                model.Notes         = Notes;
                await _workoutService.LogWorkout(currentUser, model);
            }
            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }