public static CreateEventViewModel MapToCreateEventVM(CalendarEvent calendarEvent, ICollection<NotificationType> notificationType, ICollection<Repeatable> repeatable, List<string> emails) { CreateEventViewModel eventVM = new CreateEventViewModel(); eventVM.Id = calendarEvent.Id; eventVM.Name = calendarEvent.Name; eventVM.Text = calendarEvent.Text; eventVM.Place = calendarEvent.Place; eventVM.Visibility = calendarEvent.Visibility; eventVM.TimeBegin = calendarEvent.TimeBegin; eventVM.AllDay = calendarEvent.AllDay; // Notification Settings List<NotificationSettingsViewModel> list = new List<NotificationSettingsViewModel>(); foreach (NotificationType item in notificationType) { list.Add(MapToNotificationSettingsViewModel(item)); } eventVM.notificationSettings = list; // Repeatable Settings List<RepeatableSettingsViewModel> listr = new List<RepeatableSettingsViewModel>(); foreach (Repeatable item in repeatable) { listr.Add(MapToRepeatableSettingsViewModel(item)); } eventVM.notificationSettings = list; eventVM.GuestsEmails = emails; return eventVM; }
// -------- Events -------- public static DisplayEventViewModel MapToDisplayEventVM(CalendarEvent calendarEvent) { DisplayEventViewModel eventVM = new DisplayEventViewModel(); eventVM.Id = calendarEvent.Id; eventVM.Name = calendarEvent.Name; eventVM.Text = calendarEvent.Text; eventVM.Place = calendarEvent.Place; eventVM.TimeBegin = calendarEvent.TimeBegin; eventVM.NotificationCount = calendarEvent.Notifications.Count; if (calendarEvent.CalendarId != null) { eventVM.CalendarId = (int)calendarEvent.CalendarId; eventVM.CalendarName = calendarEvent.Calendar.Name; } return eventVM; }
public static CalendarEvent MapToEvent(CreateEventViewModel eventVM) { CalendarEvent calendarEvent = new CalendarEvent(); calendarEvent.Name = eventVM.Name; calendarEvent.Text = eventVM.Text; calendarEvent.Place = eventVM.Place; calendarEvent.TimeBegin = eventVM.TimeBegin; calendarEvent.TimeEnd = eventVM.TimeEnd; calendarEvent.Visibility = eventVM.Visibility; calendarEvent.AllDay = eventVM.AllDay; return calendarEvent; }