public EventViewModel(Models.Event @event) { Id = @event.Id; if (@event.Campaign != null) { CampaignId = @event.Campaign.Id; CampaignName = @event.Campaign.Name; TimeZoneId = @event.Campaign.TimeZoneId; if (@event.Campaign.ManagingOrganization != null) { OrganizationId = @event.Campaign.ManagingOrganization.Id; OrganizationName = @event.Campaign.ManagingOrganization.Name; HasPrivacyPolicy = !string.IsNullOrEmpty(@event.Campaign.ManagingOrganization.PrivacyPolicy); } } Title = @event.Name; Description = @event.Description; EventType = @event.EventType; StartDateTime = @event.StartDateTime; EndDateTime = @event.EndDateTime; if (@event.Location != null) { Location = new LocationViewModel(@event.Location); } IsClosed = EndDateTime.UtcDateTime < DateTimeOffset.UtcNow; ImageUrl = @event.ImageUrl; Tasks = @event.Tasks != null ? new List<TaskViewModel>(@event.Tasks.Select(data => new TaskViewModel(data)).OrderBy(task => task.StartDateTime)) : new List<TaskViewModel>(); SignupModel = new Shared.TaskSignupViewModel(); //mgmccarthy: this check doesn't make much sense unless you explicitly set @event.RequiredSkills to null. If you look at the Event model, you'll see that RequireSkills is instaniated with //a new empty list: "public List<EventSkill> RequiredSkills { get; set; } = new List<EventSkill>();". I think this can go away? RequiredSkills = @event.RequiredSkills?.Select(ek => new SkillViewModel(ek.Skill)).ToList(); IsLimitVolunteers = @event.IsLimitVolunteers; IsAllowWaitList = @event.IsAllowWaitList; Headline = @event.Headline; }
public EventViewModel(Models.Event @event) { Id = @event.Id; if (@event.Campaign != null) { CampaignId = @event.Campaign.Id; CampaignName = @event.Campaign.Name; if (@event.Campaign.ManagingOrganization != null) { OrganizationId = @event.Campaign.ManagingOrganization.Id; OrganizationName = @event.Campaign.ManagingOrganization.Name; HasPrivacyPolicy = !string.IsNullOrEmpty(@event.Campaign.ManagingOrganization.PrivacyPolicy); } } Title = @event.Name; Description = @event.Description; EventType = @event.EventType; TimeZoneId = @event.TimeZoneId; StartDateTime = @event.StartDateTime; EndDateTime = @event.EndDateTime; if (@event.Location != null) { Location = new LocationViewModel(@event.Location); } IsClosed = EndDateTime.UtcDateTime < DateTimeOffset.UtcNow; ImageUrl = @event.ImageUrl; Tasks = @event.Tasks != null ? new List <TaskViewModel>(@event.Tasks.Select(data => new TaskViewModel(data)).OrderBy(task => task.StartDateTime)) : new List <TaskViewModel>(); SignupModel = new Shared.TaskSignupViewModel(); //mgmccarthy: this check doesn't make much sense unless you explicitly set @event.RequiredSkills to null. If you look at the Event model, you'll see that RequireSkills is instaniated with //a new empty list: "public List<EventSkill> RequiredSkills { get; set; } = new List<EventSkill>();". I think this can go away? RequiredSkills = @event.RequiredSkills?.Select(ek => new SkillViewModel(ek.Skill)).ToList(); IsLimitVolunteers = @event.IsLimitVolunteers; IsAllowWaitList = @event.IsAllowWaitList; Headline = @event.Headline; }