コード例 #1
0
        public ActionResult RateStepResource(int id)
        {
            var roadStep = Db.RoadSteps
                           .Include(p => p.StepResources)
                           .FirstOrDefault(p => p.Id == id);

            var model = new RateStepContentViewModel();

            model.RoadStep            = roadStep;
            model.RoadStepId          = roadStep.Id;
            model.StepResourceRatings = MapStepResourceToDto(roadStep.StepResources);
            return(View(model));
        }
コード例 #2
0
        public ActionResult RateStepResource(RateStepContentViewModel model)
        {
            var roadStep = Db.RoadSteps
                           .Include(p => p.StepResources)
                           .FirstOrDefault(p => p.Id == model.RoadStepId);
            var currentStudent = CurrentStudentWithRoadSteps;

            currentStudent.AddFinishedResourcesComment(roadStep, model.Comment);
            foreach (var rating in model.StepResourceRatings)
            {
                currentStudent.RateResource(roadStep, rating.Id, rating.RatingValue);
            }
            Db.SaveChanges();

            return(RedirectToAction("Step", "Library", new { @id = model.RoadStepId }));
        }