/// <summary> /// Create a new Event object. /// </summary> /// <param name="eventId">Initial value of the EventId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="eventDate">Initial value of the EventDate property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> public static Event CreateEvent(global::System.Int32 eventId, global::System.String name, global::System.DateTime eventDate, global::System.Boolean isDeleted) { Event @event = new Event(); @event.EventId = eventId; @event.Name = name; @event.EventDate = eventDate; @event.IsDeleted = isDeleted; return @event; }
/// <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); }
/// <summary> /// Saves this event. /// </summary> /// <returns></returns> public bool Save() { if (EventDate < DateTime.Today.Date) throw new ArgumentException("Ugyldig dato for stevne"); using (var context = new Entities()) { var newEvent = new Event(); newEvent.Name = Name; newEvent.EventDate = EventDate; try { context.Events.AddObject(newEvent); context.SaveChanges(); EventId = newEvent.EventId; return true; } catch (Exception) { return false; } } }