/// <summary> /// Create a new Event object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="created">Initial value of the Created property.</param> public static Event CreateEvent(global::System.Int32 id, global::System.String name, global::System.DateTime created) { Event @event = new Event(); @event.ID = id; @event.Name = name; @event.Created = created; return @event; }
public ActionResult New(EventViewModel eventView) { Member winner = ValidateWinner(eventView.Winner); // create a new event if (!ModelState.IsValid) { eventView.Venues = _venuesRepository.GetAll().Select(v => v.Name); eventView.Members = _membersRepository.GetAll().Select(m => m.Name); return View(eventView); } var newEvent = new Event { Name = eventView.Name, WinnerID = winner != null ? winner.ID : (int?)null, When = eventView.StartDate, Cost = eventView.Cost }; if (!string.IsNullOrEmpty(eventView.Venue)) { var venue = _venuesRepository.Get(eventView.Venue); if (venue == null) { // venue doesn't exist newEvent.Venue = new Venue { Name = eventView.Venue, AddressLine1 = eventView.AddressLine1, AddressLine2 = eventView.AddressLine2 }; } else { // update address of existing venue venue.AddressLine1 = eventView.AddressLine1; venue.AddressLine1 = eventView.AddressLine1; newEvent.Venue = venue; } } _eventsRepository.Create(newEvent); return RedirectToAction("Index"); }
/// <summary> /// Deprecated Method for adding a new object to the Events EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToEvents(Event @event) { base.AddObject("Events", @event); }