public IEnumerable <ExerciseViewModel> Get() { var x = exerciseManager.GetAll(); Mapper.Initialize(cfg => { cfg.CreateMap <Exercise, ExerciseViewModel>(); }); var collection = new List <ExerciseViewModel>(); foreach (var item in x) { collection.Add(Mapper.Map <Exercise, ExerciseViewModel>(item)); } return(collection); }
public IActionResult History() { try { var userName = User.Identity.Name; var user = userManager.Users.Where(e => e.UserName == userName).FirstOrDefault(); var codelst = codeManager.Get().Where(e => e.UserId == user.Id).ToList(); var history = codeManager.GetAll().ToList(); var exercise = exerciseManager.GetAll().ToList(); return(View(new CodeHistoryViewModels { CodeHistory = history, Exercises = exercise, UserCode = codelst, UserName = user.UserName })); } catch (Exception ex) { } return(View()); }
public IActionResult Index() { var exerciseList = exerciseManager.GetAll(); return(View(exerciseList)); }