示例#1
0
        public void AddParticipant(string name, int age, Domain.Event event1, Domain.Event event2)
        {
            Domain.AgeGroup?ageGroup = null;
            foreach (Domain.AgeGroup ag in Enum.GetValues(typeof(Domain.AgeGroup)))
            {
                (int, int)ageBorders = ParseAgeGroup(ag);
                if (age >= ageBorders.Item1 && age <= ageBorders.Item2)
                {
                    ageGroup = ag;
                    break;
                }
            }
            if (ageGroup == null)
            {
                throw new Exception("Invalid age group");
            }

            Domain.Child child = new Domain.Child {
                Name = name, Age = age
            };
            child.Id = ChildRepo.Save(child);
            EntryRepo.Save(new Entry {
                Child = child, Event1 = event1, Event2 = event2, AgeGroup = ageGroup.Value
            });

            NotifyEvents();
        }
示例#2
0
        protected void RaiseEvent(Event @event)
        {
            if (Version == 0)
            {
                if (@event.AggregateId == Guid.Empty)
                    @event.AggregateId = Guid.NewGuid(); //TODO: Combed Guid?

                this.Id = @event.AggregateId;
            }

            @event.AggregateId = this.Id;
            @event.Timestamp = DateTime.UtcNow;
            @event.EventId = Guid.NewGuid(); //TODO: Flake or combed guid?

            ApplyEvent(@event);
            _uncommittedEvents.Add(@event);
        }
示例#3
0
        /// <summary>
        /// Adds the event to the database.
        /// </summary>
        /// <param name="event">The event.</param>
        /// <returns>
        /// THe id of the event added to database
        /// </returns>
        public int InsertEvent(Domain.Event @event)
        {
            using (var unitOfWork = this.unitOfWorkFactory.Create())
            {
                // Get the event entity repository
                IEntityRepository <Event> entityRepository = unitOfWork.GetRepository <Event, int>();

                // Insert the event
                entityRepository.Insert(@event);

                // Persist the changes
                IList <ObjectStateEntry> changes = unitOfWork.Save();

                // Return the Id of the added beverage
                return(changes.GetInsertedEntityKey <int>("Events"));
            }
        }
示例#4
0
        public static externalDTO.Event MapFromDomain(internalDTO.Event Event)
        {
            var res = Event == null ? null : new externalDTO.Event()
            {
                Id                  = Event.Id,
                Name                = Event.Name,
                Description         = Event.Description,
                NextEventId         = Event.NextEventId,
                SubEventId          = Event.SubEventId,
                AppUserId           = Event.AppUserId,
                AdministrativeUnits = Event.EventAdministrativeUnit?.Select(item => AdministrativeUnitMapper.MapFromDomain(item.AdministrativeUnit)).ToList(),
                Locations           = Event.EventLocations?.Select(item => LocationMapper.MapFromDomain(item.Location)).ToList(),
                EventTypes          = Event.EventTypes?.Select(item => EventTypeMapper.MapFromDomain(item.EventType)).ToList(),
                ImageSrc            = Event.ImageSrc,
                EventDate           = Event.EventDate
            };

            return(res);
        }
示例#5
0
 public IEnumerable <Domain.DTO.ChildNoEventsDTO> GetChildrenNoEvents(Domain.Event e, Domain.AgeGroup a)
 {
     return(ChildRepo.GetChildrenNoEvents(e, a));
 }
示例#6
0
 public static Event Create(string title, DateTime start)
 {
     var ev = new Event();
     ev.Update(title, start);
     return ev;
 }