int IEventRepository.SaveItem(EventDto eventDto) { var existingEvent = _context.Events.FirstOrDefault(e => e.ChurchId == eventDto.ChurchId && e.Name == eventDto.Name); if (existingEvent != null) return existingEvent.EventId; var newEvent = new Event(); Mapper.Map(eventDto, newEvent); _context.AddToEvents(newEvent); _context.SaveChanges(); return newEvent.EventId; }
/// <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> /// Create a new Event object. /// </summary> /// <param name="eventId">Initial value of the EventId property.</param> /// <param name="churchId">Initial value of the ChurchId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="showInGroupScreen">Initial value of the ShowInGroupScreen property.</param> /// <param name="eventOrder">Initial value of the EventOrder property.</param> public static Event CreateEvent(global::System.Int32 eventId, global::System.Int32 churchId, global::System.String name, global::System.Boolean showInGroupScreen, global::System.Int32 eventOrder) { Event @event = new Event(); @event.EventId = eventId; @event.ChurchId = churchId; @event.Name = name; @event.ShowInGroupScreen = showInGroupScreen; @event.EventOrder = eventOrder; return @event; }