Example #1
0
        public virtual ActionResult Edit(string id)
        {
            var model = QuizEditModel.FromDomain(Quizs.Get(id), Accounting);

            ViewData["groups"] = GroupSummaries;
            ViewData["users"]  = UserSummaries[model.Availability.Users ?? new string[0]];
            return(View(model));
        }
Example #2
0
        public static QuizEditModel FromDomain(Quiz q, IAccountingService accounting)
        {
            var x = new QuizEditModel {
                MaxTaken               = q.MaxTaken,
                MaxAwarded             = q.MaxAwarded,
                Cooldown               = (null == q.Cooldown) ? null : (int?)q.Cooldown.Value.TotalDays,
                AllowReview            = q.AllowReview,
                FlatPointValue         = q.FlatPointValue,
                CorrectAnswersRequired = q.CorrectAnswersRequired,
                Questions              = q.Questions,
            };

            x.Init(q, accounting);
            return(x);
        }
Example #3
0
        public virtual ActionResult Edit(string id, QuizEditModel q)
        {
            var x = Quizs.Get(id);

            if (!ModelState.IsValid)
            {
                return(View(q));
            }
            try
            {
                q.Apply(x, Accounting);
                Quizs.Save(x);
                return(this.RedirectToAction(c => c.Index()));
            }
            catch (Exception ex)
            {
                ViewData["groups"] = GroupSummaries;
                ViewData["users"]  = UserSummaries[q.Availability.Users ?? new string[0]];
                Notifier.Notify(ex);
                return(View(q));
            }
        }