Example #1
0
        public UserCodeReviewViewModel Get(int id)
        {
            var userCode = codeManager.Get(c => c.Id == id).First();
            var exercise = exerciseManager.GetById(userCode.ExerciseId);

            return(new UserCodeReviewViewModel()
            {
                UserCodeDTO = userCode,
                ExerciseName = exercise.TaskName,
                ExerciseTask = exercise.TaskTextField
            });
        }
        public async Task <ActionResult> Delete(string id)
        {
            User user = await this.userManager.FindByIdAsync(id);

            var code = codeManager.Get().Where(e => e.UserId == user.Id).FirstOrDefault();

            if (user != null)
            {
                codeManager.DeleteHistoryLst(code);
                codeManager.DeleteCode(code);
                await this.userManager.DeleteAsync(user);
            }
            return(RedirectToAction("Users"));
        }
Example #3
0
        public IActionResult ExerciseSolutionsIndex(int id)
        {
            List <UserCodeListUnitViewModel> codesList = new List <UserCodeListUnitViewModel>();
            var solutionsList = codeManager.Get(c => c.ExerciseId == id && (c.CodeStatus == Model.Entity.CodeStatus.Done || c.CodeStatus == Model.Entity.CodeStatus.Appreciated));

            if (solutionsList != null)
            {
                foreach (var elem in solutionsList)
                {
                    codesList.Add(new UserCodeListUnitViewModel
                    {
                        codeUnit = elem,
                        UserName = userManager.FindByIdAsync(elem.UserId).Result.UserName
                    });
                }
            }
            UserCodeListViewModel model = new UserCodeListViewModel {
                userCodeList = codesList
            };

            return(View(model));
        }
Example #4
0
        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());
        }