Пример #1
0
        public ActionResult TrialAssessment(TrialAssessmentViewModel model)
        {
            TrialAssessmentViewModel returnModel = null;

            if (!ModelState.IsValid)
            {
                returnModel = skillHelper.BuildTrialAssessmentViewModel(model);

                return(View("~/Views/Player/Skill/TrialAssessment.cshtml", returnModel));
            }

            var dataModel = new TrialAssessmentDataModel
            {
                AssignedNumber   = (int)model.AssignedNumber,
                Drill            = model.SelectedDrill,
                Rating           = (int)model.SelectedRating,
                UserId           = User.Identity.GetUserId(),
                DateOfAssessment = model.DateOfAssessment
            };

            dbContext.TrialAssessments.Add(dataModel);
            dbContext.SaveChanges();

            ViewBag.Saved = "Assessment Submitted!";

            returnModel = skillHelper.BuildTrialAssessmentViewModel(null);

            return(View("~/Views/Player/Skill/TrialAssessment.cshtml",
                        returnModel));
        }
        public TrialAssessmentViewModel BuildTrialAssessmentViewModel(TrialAssessmentViewModel model)
        {
            model = model ?? new TrialAssessmentViewModel
            {
                SelectedDrill    = "",
                SelectedRating   = null,
                DateOfAssessment = DateTime.Now
            };

            model.Drills  = playerHelper.BuildDrillList();
            model.Ratings = playerHelper.BuildRatingList();

            return(model);
        }