예제 #1
0
        public async void CreateAdmin(Admin admin)
        {
            await adminHandler.Post(admin);

            //Tilføjer til cataloget så reload er unødvendig
            AdminCatalogSingleton.Instance.Admins.Add(admin);
        }
예제 #2
0
        public async void CreateParticipant(Participant participant)
        {
            await participantFacade.Post(participant);

            //Tilføjer til cataloget så reload er unødvendig
            ParticipantCatalogSingleton.Instance.Participants.Add(participant);
        }
예제 #3
0
        public async void CreateSpeaker(Speaker speaker)
        {
            await SpeakerFacade.Post(speaker);

            //Tilføjer til cataloget så reload er unødvendig
            SpeakerCatalogSingleton.Instance.Speakers.Add(speaker);
        }
예제 #4
0
        /// <summary>
        /// Add an event to the catalog
        /// </summary>
        /// <param name="event">The event to add</param>
        /// <param name="getId">If true an new id will be made if the events id is not unique if false and exception will be thrown if its not</param>
        /// <returns>Whether the event was succesfully added</returns>
        public async Task <bool> Add(Event @event, bool getId)
        {
            if (_collection.SingleOrDefault((x) => x.Id == @event.Id) != null)
            {
                if (getId)
                {
                    @event.Id = GetUniqueId();
                }
                else
                {
                    throw new ItIsNotUniqueException("Begivenhedens id er ikke unikt");
                }
            }
            CheckSpeaker(@event);
            CheckRoom(@event);
            CheckDate(@event);
            CheckImage(@event, false);

            _collection.Add(@event);
            bool ok = await _eventPersistence.Post(@event);

            if (!ok)
            {
                _collection.Remove(@event);
                throw new BaseException("Thing no. 1. you thought would never happen. But of course it did");
            }
            return(true);
        }
예제 #5
0
        public async Task AddRegistration(Event @event, Participant participant)
        {
            Registration registration = new Registration(GetUniqueId(), participant.UserName, @event.Id);
            bool         ok           = await _registrationPersistence.Post(registration);

            if (ok)
            {
                Registrations.Add(registration);
                RegistrationDictionary[@event].Add(participant);
            }
            else
            {
                throw new BaseException("Add regi fail");
            }
        }
예제 #6
0
        /// <summary>
        /// Denne metode bliver brugt til at oprette et lokale
        /// </summary>
        /// <returns>et nyt lokale</returns>
        public async Task CreateRoom()
        {
            Validate();
            if (DoesExist())
            {
                throw new ItIsNotUniqueException("Something");
            }

            bool ok = await _genericPersistence.Post(RoomViewModel.NewRoom);

            if (!ok)
            {
                await MessageDialogUtil.MessageDialogAsync("Der skete en fejl i Room", "Lokalet blev ikke oprettet");
            }
            else
            {
                RoomViewModel.RoomCatalog.Rooms.Add(RoomViewModel.NewRoom);
                await MessageDialogUtil.MessageDialogAsync("Alt gik godt", $"Lokalet blev oprettet");

                RoomViewModel.NewRoom = new Room();
            }
        }