public ActionResult PutEvent(int id, EventDTO eventDTO)
        {
            Event eventToEdit = _eventRepository.GetById(id);

            if (eventToEdit == null)
            {
                return(NotFound());
            }
            else
            {
                eventToEdit.Name           = eventDTO.Name;
                eventToEdit.Description    = eventDTO.Description;
                eventToEdit.StartDate      = eventDTO.StartDate;
                eventToEdit.EndDate        = eventDTO.EndDate;
                eventToEdit.Country        = eventDTO.Country;
                eventToEdit.Region         = eventDTO.Region;
                eventToEdit.City           = eventDTO.City;
                eventToEdit.Street         = eventDTO.Street;
                eventToEdit.StreetNr       = eventDTO.StreetNr;
                eventToEdit.ZipCode        = eventDTO.ZipCode;
                eventToEdit.HeaderImageURL = eventDTO.HeaderImageURL;

                foreach (var eventGenre in eventToEdit.EventGenres)
                {
                    Genre genreToRemove = eventGenre.Genre;
                    eventToEdit.RemoveEventGenre(genreToRemove);
                    EventGenreDTO eventGenreFromDTO = eventDTO.EventGenres.SingleOrDefault(eg => eg.GenreId == eventGenre.GenreId);
                    Genre         genreToAdd        = _genreRepository.GetById(eventGenreFromDTO.GenreId);
                    eventToEdit.AddEventGenre(genreToAdd);
                }

                foreach (var price in eventToEdit.Prices)
                {
                    PriceDTO priceFromDTO = eventDTO.Prices.SingleOrDefault(p => p.PriceId == price.PriceId);
                    price.Name        = priceFromDTO.Name;
                    price.Description = priceFromDTO.Description;
                    price.Cost        = priceFromDTO.Cost;
                }

                foreach (var link in @eventToEdit.Links)
                {
                    LinkDTO linkFromDTO = eventDTO.Links.SingleOrDefault(l => l.LinkId == link.LinkId);
                    link.Name = linkFromDTO.Name;
                    link.Url  = linkFromDTO.Url;
                }

                _eventRepository.Update(eventToEdit);
                _eventRepository.SaveChanges();
                return(Ok(eventToEdit));
            }
        }
 public ActionResult <Event> PostPrice(int id, EventGenreDTO eventGenreDTO)
 {
     try {
         Event @event = _eventRepository.GetById(id);
         if (@event == null)
         {
             return(NotFound());
         }
         else
         {
             Genre genreToAdd = _genreRepository.GetById(eventGenreDTO.GenreId);
             @event.AddEventGenre(genreToAdd);
             _eventRepository.SaveChanges();
             return(CreatedAtAction(nameof(GetEvent), new { id = @event.EventId }, @event));
         }
     }
     catch (Exception ex) {
         return(BadRequest(ex.Message));
     }
 }