Пример #1
0
 public static GameViewModel FromDomain(Game g)
 {
     return(new GameViewModel
     {
         Content = ContentViewModel.FromDomain(g.Content),
         TimeLimit = g.TimeLimit,
     });
 }
Пример #2
0
        public static QuizViewModel FromDomain(Quiz q)
        {
            var markdown = new Markdown();

            return(new QuizViewModel
            {
                Content = ContentViewModel.FromDomain(q.Content),
                Questions = q.Questions.Select(
                    x => new QuizViewModelQuestion
                {
                    Title = x.Title,
                    Content = String.IsNullOrEmpty(x.Content) ? null : markdown.Transform(x.Content),
                    Answers = x.Answers.Select(y => y.Title),
                }),
            });
        }
Пример #3
0
        public static SurveyViewModel FromDomain(Survey s)
        {
            var markdown = new Markdown();

            return(new SurveyViewModel
            {
                Content = ContentViewModel.FromDomain(s.Content),
                Questions = s.Questions.Select(
                    x => new SurveyViewModelQuestion
                {
                    Title = x.Title,
                    Content = String.IsNullOrEmpty(x.Content) ? null : markdown.Transform(x.Content),
                    Freeform = x.Freeform,
                    Answers = x.Answers == null ? null : x.Answers.Select(y => y.Title),
                }),
            });
        }
Пример #4
0
 public static AwardViewModel FromDomain(User u, Award a, IUserRepository userRepository, IAccountingService accounting, HttpRequestBase request)
 {
     return(new AwardViewModel
     {
         From = u.DisplayName,
         Content = ContentViewModel.FromDomain(a.Content),
         Certificates =
             (a.Certificates ?? new List <Certificate>()).Where(x => x.Enabled).Select(
                 x => CertificateViewModel.FromDomain(x, request)),
         Issuance = a.Issuance,
         MaxAward = accounting.GetMaxProgramAward(a, u) ?? 0,
         Nominees = userRepository
                    .GetSummaries()
                    .Where(x => x.Id != u.Document.Id && a.IsValidNominee(x))
                    .ToList(),
     });
 }
Пример #5
0
        public virtual ActionResult Terms()
        {
            // look at either the application default tos or the group specific tos
            var page = Application.DefaultTermsOfService;

            if (null != CurrentGroup &&
                !String.IsNullOrEmpty(CurrentGroup.TermsOfService))
            {
                page = CurrentGroup.TermsOfService;
            }

            ViewData["updated"] = CurrentUser.DateAcceptedTermsOfService.HasValue;
            try
            {
                return(View(ContentViewModel.FromDomain(Pages[page].Content)));
            }
            catch
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "No terms of service page could be found.");
            }
        }
Пример #6
0
 public static PageViewModel FromDomain(Page p)
 {
     return(new PageViewModel {
         Content = ContentViewModel.FromDomain(p.Content),
     });
 }