Beispiel #1
0
 public static ClassModel Create(Data.Event e, string userId) => new ClassModel
 {
     Id                     = e.Id,
     Title                  = e.Title,
     Description            = e.Description,
     SignupHelp             = e.SignupOptions.SignupHelp,
     OpensAt                = e.SignupOptions.SignupOpensAt,
     IsOpen                 = e.IsOpen(),
     RoleSignup             = e.SignupOptions.RoleSignup,
     RoleSignupHelp         = e.SignupOptions.RoleSignupHelp,
     AllowPartnerSignup     = e.SignupOptions.AllowPartnerSignup,
     AllowPartnerSignupHelp = e.SignupOptions.AllowPartnerSignupHelp,
     Signup                 = e.Signups
                              .Select(s => ClassSignupModel.Create(s))
                              .FirstOrDefault(s => s.UserId == userId)
 };
Beispiel #2
0
        public async Task <IActionResult> Index()
        {
            var userId = _userManager.GetUserId(User);

            var signups = await _memberContext.EventSignups
                          .Include(s => s.Event)
                          .Include(s => s.User)
                          .AsNoTracking()
                          .Expressionify()
                          .Where(s => s.UserId == userId)
                          .Where(s => s.Event.Type == EventType.Class)
                          .Where(s => !s.Event.Archived)
                          .OrderBy(s => s.Priority)
                          .Select(s => ClassSignupModel.Create(s))
                          .ToListAsync();

            return(View(new IndexModel
            {
                Signups = signups
            }));
        }