public IActionResult ViewRecords(int WorkoutID, int ExerciseID) { string user = User.Identity.Name; ApplicationUser userLoggedIn = context .Users .Single(c => c.UserName == user); Exercise exercise = context .Exercises .Single(c => c.ExerciseID == ExerciseID); List <Record> records = context .Records .Include(c => c.ExerciseRecords) .Where(c => c.FK_ExerciseID == ExerciseID && c.WorkoutID == WorkoutID) .ToList(); ViewRecordViewModel viewModel = new ViewRecordViewModel { Exercise = exercise, Records = records }; return(View(viewModel)); }
public async Task <bool> SaveViewRecord([FromBody] ViewRecordViewModel viewRecord) { TimeSpan TotalTimeViewVideo = Convert.ToDateTime(viewRecord.End_time) - Convert.ToDateTime(viewRecord.Start_time); TB_EL_View_Record view_Record = new TB_EL_View_Record { Account = viewRecord.Account, End_time = Convert.ToDateTime(viewRecord.End_time), Name = viewRecord.Name, Path = viewRecord.Path, SID = viewRecord.SID, Start_time = Convert.ToDateTime(viewRecord.Start_time), Subject = viewRecord.Subject, Work_Id = viewRecord.Work_Id, Total_time = Convert.ToInt32(TotalTimeViewVideo.TotalSeconds), Factory = viewRecord.Factory, Dept = viewRecord.Dept }; return(await _homeService.SaveViewRecord(view_Record)); }
public IActionResult RecordIndexExercise(int id) { string user = User.Identity.Name; ApplicationUser userLoggedIn = context.Users.Single(c => c.UserName == user); List <ExerciseWorkout> exercises = context .ExerciseWorkouts .Include(item => item.Exercise) .Where(cm => cm.WorkoutID == id && cm.Workout.OwnerId == userLoggedIn.Id)//cm.Workout.OwnerId == userLoggedIn.Id returns list of owner specific workouts .ToList(); Workout workout = context .Workouts .Single(m => m.WorkoutID == id); //Only needed for title in page and to link to add an exercise ViewRecordViewModel viewModel = new ViewRecordViewModel { Workout = workout, ExerciseWorkouts = exercises }; return(View(viewModel)); }