public ViewEventViewModel(Event eventModel) { this.EventId = eventModel.EventId; this.Title = eventModel.Title; this.Description = eventModel.Description; this.Date = eventModel.Date; this.Time = eventModel.Time; this.FirstReminderMail = eventModel.FirstReminderMail; this.SecondReminderMail = eventModel.SecondReminderMail; this.ReplyDeadline = eventModel.ReplyDeadline; this.AcceptanceEvent = eventModel.AcceptanceEvent; this.Address = new AddressViewViewModel(eventModel.Address); }
private void CreateEmailsToBeSent(Event eventModel) { // Replace wildcards in Email Text var description = eventModel.Description; description = description.Replace("%%Datum%%", eventModel.Date.ToShortDateString()); description = description.Replace("%%Uhrzeit%%", eventModel.Date.ToShortTimeString()); foreach (var participant in eventModel.Participants) { // Check if participant already got an email var sentmail = db.ScheduledEmails.FirstOrDefault(m => m.ParticipantId == participant.ParticipantId); if(sentmail != null) continue; var email = new ScheduledEmail(); email.EmailSent = false; email.EmailText = description; email.EventId = eventModel.EventId; email.MemberId = participant.Member.MemberId; email.ParticipantId = participant.ParticipantId; email.AnswerCode = participant.SecurityCode; email.ScheduledDate = DateTime.Now; db.ScheduledEmails.Add(email); var reminderMail = new ScheduledEmail(); reminderMail.EmailSent = false; reminderMail.EmailText = description; reminderMail.EventId = eventModel.EventId; reminderMail.MemberId = participant.Member.MemberId; reminderMail.ParticipantId = participant.ParticipantId; reminderMail.AnswerCode = participant.SecurityCode; reminderMail.ScheduledDate = eventModel.FirstReminderMail; db.ScheduledEmails.Add(reminderMail); db.SaveChanges(); } }
private Event UpdateEvent(Event eventModel, CreateEventViewModel eventViewModel) { eventModel.Address.City = eventViewModel.Address.City; eventModel.Address.HouseNumber = eventViewModel.Address.HouseNumber; eventModel.Address.StreetName = eventViewModel.Address.StreetName; eventModel.Address.Zip = eventViewModel.Address.Zip; eventModel.Date = eventViewModel.Date; eventModel.Time = eventViewModel.Time; eventModel.Description = eventViewModel.Description; eventModel.ReplyDeadline = eventViewModel.ReplyDeadline; eventModel.FirstReminderMail = eventViewModel.FirstReminderMail; eventModel.SecondReminderMail = eventViewModel.SecondReminderMail; eventModel.Title = eventViewModel.Title; eventModel.AcceptanceEvent = eventViewModel.AcceptanceEvent; eventModel.DateEdited = DateTime.Now; return eventModel; }
private Event CreateEvent(CreateEventViewModel eventViewModel) { var address = new Address { City = eventViewModel.Address.City, HouseNumber = eventViewModel.Address.HouseNumber, StreetName = eventViewModel.Address.StreetName, Zip = eventViewModel.Address.Zip }; var createEvent = new Event { DateCreated = DateTime.Now, Title = eventViewModel.Title, Description = eventViewModel.Description, DateEdited = DateTime.Now, Date = eventViewModel.Date, Time = eventViewModel.Time, ReplyDeadline = eventViewModel.ReplyDeadline, FirstReminderMail = eventViewModel.FirstReminderMail, SecondReminderMail = eventViewModel.SecondReminderMail, AcceptanceEvent = eventViewModel.AcceptanceEvent, Address = address, Participants = new List<Participant>() }; return createEvent; }
private ViewEventViewModel ViewEvent(Event eventModel) { var addressViewModel = new AddressViewViewModel { City = eventModel.Address.City, HouseNumber = eventModel.Address.HouseNumber, StreetName = eventModel.Address.StreetName, Zip = eventModel.Address.Zip }; var eventViewModel = new ViewEventViewModel { EventId = eventModel.EventId, Title = eventModel.Title, Description = eventModel.Description, Date = eventModel.Date, Time = eventModel.Time, ReplyDeadline = eventModel.ReplyDeadline, FirstReminderMail = eventModel.FirstReminderMail, SecondReminderMail = eventModel.SecondReminderMail, AcceptanceEvent = eventModel.AcceptanceEvent, Address = addressViewModel }; return eventViewModel; }