public static Notification MeetupUpdated(Meetup newMeetup, DateTime originalDateTime, string originalVenue) { var notification = new Notification(NotificationType.MeetupUpdated, newMeetup); // Be sure that OriginalDateTime and OriginalVenue properties have private setters to prevent them // from being changed. They can only be changed when the right factory method is called. notification.OriginalDateTime = originalDateTime; notification.OriginalVenue = originalVenue; return notification; }
private Notification(NotificationType type, Meetup meetup) { if (meetup == null) { throw new ArgumentNullException("meetup"); } Type = type; Meetup = meetup; DateTime = DateTime.Now; }
public static Notification MeetupCancelled(Meetup meetup) { return new Notification(NotificationType.MeetupCancelled, meetup); }
[ValidateAntiForgeryToken] // This is to prevent Cross-site Request Forgery (CSRF) attacks. public ActionResult Create(MeetupFormViewModel viewModel) { // If our view model is not valid, return the user back to the Create view with // validation messages showing. if (!ModelState.IsValid) { // We have to re-initialize our Categories list or a null exception will be thrown. viewModel.Categories = _context.Categories.ToList(); return View("MeetupForm", viewModel); } var meetup = new Meetup { GroupId = User.Identity.GetUserId(), DateTime = viewModel.GetDateTime(), CategoryId = viewModel.Category, Venue = viewModel.Venue, Title = viewModel.Title, Description = viewModel.Description }; _context.Meetups.Add(meetup); _context.SaveChanges(); return RedirectToAction("Mine", "Meetups"); }