Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            var dinnerEvent = new DinnerEvent
            {
                EventName         = Input.EventName,
                EventDate         = Input.EventDate,
                LastRegisterDate  = Input.LastRegisterDate,
                PartyLocation     = Input.PartyLocation,
                PartyLocationName = Input.PartyLocationName,
                City             = Input.City,
                EventPictureLink = Input.EventPictureLink,
                RoutesOpen       = false
            };

            _dinnerEventsRepository.Insert(dinnerEvent);
            _dinnerEventsRepository.SaveChanges();
            var apiKey    = _configuration.GetEmailSettings("apiKey");
            var apiSecret = _configuration.GetEmailSettings("apiSecret");
            int id        = await _emailSender.CreateContactListAsync(apiKey, apiSecret, Input.EventName);

            if (id != 0)
            {
                dinnerEvent.ContactList = id;
                _dinnerEventsRepository.Update(dinnerEvent);
            }

            _dinnerEventsRepository.SaveChanges();
            StatusMessage = "Dein Event wurde erstellt.";
            return(RedirectToPage());
        }