public ListResultModel<VenueModel> GetVenueForPerformances(long? id, PerformanceFilterRequest filter)
        {
            IPerformanceDao performanceDao = DaoFactory.CreatePerformanceDao();
            ListResultModel<VenueModel> model;
            if ((model = HandleAuthentication<ListResultModel<VenueModel>>()) == null)
            {
                model = new ListResultModel<VenueModel>();
                try
                {
                    IList<Performance> entities = performanceDao.GetFilteredPerformancesForExport(id, filter.StartDate, filter.EndDate, filter.ArtistIds, filter.VenueIds, filter.ArtistGroupIds, filter.ArtistCategoryIds, filter.Countries, true, filter.Moved);
                    IDictionary<Venue, List<Performance>> mapEntities = entities.GroupBy(entity => entity.Venue).ToDictionary(entry => entry.Key, entry => entry.ToList());
                    model.Result = mapEntities.Select(entry =>
                    {
                        Venue venue = entry.Key;
                        List<Performance> performances = entry.Value;
                        VenueModel venueModel = new VenueModel
                        {
                            Id = venue.Id.Value,
                            Name = venue.Name,
                            FullAddress = (new StringBuilder(venue.Street).Append(", ").Append(venue.Zip).Append(venue.City).Append(" AT").ToString()),
                            GpsCoordinates = venue.GpsCoordinate,
                            Performances = performances.Select(item => new PerformanceModel
                            {
                                Id = item.Id.Value,
                                Version = item.Version.Value,
                                StartDate = item.StartDate.Value,
                                EndDate = item.EndDate.Value,
                                FormerStartDate = item.FormerStartDate,
                                FormerEndDate = item.FormerEndDate,
                                Artist = new ArtistModel
                                {
                                    Id = item.Artist.Id.Value,
                                    FirstName = item.Artist.Firstname,
                                    LastName = item.Artist.Lastname,
                                    CountryCode = item.Artist.CountryCode,
                                    ArtistGroup = ((item.Artist.ArtistGroupId != null) ? item.Artist.ArtistGroup.Name : null),
                                    ArtistCategory = item.Artist.ArtistCategory.Name
                                },
                                Venue = new VenueModel
                                {
                                    Id = item.Venue.Id.Value,
                                    Name = item.Venue.Name
                                },
                                FormerVenue = ((item.FormerVenueId != null) ? new VenueModel
                                {
                                    Id = item.FormerVenue.Id.Value,
                                    Name = item.FormerVenue.Name
                                } : null)
                            }).ToList()
                        };
                        venueModel.Performances.Sort((o1, o2) => o1.StartDate.CompareTo(o2.StartDate));
                        return venueModel;
                    }).ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetVenueForPerformances: Error during processing. error: " + e.Message);
                    model.ErrorCode = (int)ErrorCode.UNKNOWN_ERROR;
                    model.Error = ($"Error during processing the request. exception={e.GetType().Name}");
                }
                finally
                {
                    DaoFactory.DisposeDao(performanceDao);
                }
            }

            return model;
        }
        public ListResultModel<VenueModel> GetVenues()
        {
            IVenueDao venueDao = DaoFactory.CreateVenueDao();
            ListResultModel<VenueModel> model;
            if ((model = HandleAuthentication<ListResultModel<VenueModel>>()) == null)
            {
                model = new ListResultModel<VenueModel>();
                try
                {
                    IList<Venue> venues = venueDao.FindAllActive();
                    model.Result = venues.Select(venue => new VenueModel
                    {
                        Id = venue.Id.Value,
                        Name = venue.Name,
                        FullAddress = (new StringBuilder(venue.Street).Append(", ").Append(venue.Zip).Append(" - ").Append(venue.City).ToString()),
                        GpsCoordinates = (venue.GpsCoordinate != null) ? venue.GpsCoordinate : null
                    }).ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetVenues: Error during processing. error: " + e.Message);
                    model.ErrorCode = (int)ErrorCode.UNKNOWN_ERROR;
                    model.Error = ($"Error during processing the request. exception={e.GetType().Name}");
                }
                finally
                {
                    DaoFactory.DisposeDao(venueDao);
                }
            }

            return model;
        }
        public ListResultModel<ArtistModel> GetSimpleArtists()
        {
            IArtistDao artistDao = DaoFactory.CreateArtistDao();
            ListResultModel<ArtistModel> model;
            if ((model = HandleAuthentication<ListResultModel<ArtistModel>>()) == null)
            {
                model = new ListResultModel<ArtistModel>();
                try
                {
                    IList<Artist> artists = artistDao.FindAllFull();
                    model.Result = artists.Select(artist => new ArtistModel
                    {
                        Id = artist.Id.Value,
                        FirstName = artist.Firstname,
                        LastName = artist.Lastname,
                        Email = artist.Email,
                        CountryCode = artist.CountryCode,
                        ArtistGroup = ((artist.ArtistGroup != null) ? artist.ArtistGroup.Name : ""),
                        ArtistCategory = ((artist.ArtistCategory != null) ? artist.ArtistCategory.Name : "")
                    }).ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetDetails: Error during processing. error: " + e.Message);
                    model.ErrorCode = (int)ErrorCode.UNKNOWN_ERROR;
                    model.Error = ($"Error during processing the request. exception={e.GetType().Name}");
                }
                finally
                {
                    DaoFactory.DisposeDao(artistDao);
                }
            }

            return model;
        }
        public ListResultModel<NameModel<long>> GetSimpleArtistCategories()
        {
            IArtistCategoryDao artistCategoryDao = DaoFactory.CreateArtistCategoryDao();
            ListResultModel<NameModel<long>> model;
            if ((model = HandleAuthentication<ListResultModel<NameModel<long>>>()) == null)
            {
                model = new ListResultModel<NameModel<long>>();
                try
                {
                    IList<ArtistCategory> categories = artistCategoryDao.FindAll();
                    model.Result = categories.Select(item => new NameModel<long>
                    {
                        Id = item.Id.Value,
                        Name = item.Name,
                    }).ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetSimpleArtistCategories: Error during processing. error: " + e.Message);
                    model.ErrorCode = (int)ErrorCode.UNKNOWN_ERROR;
                    model.Error = ($"Error during processing the request. exception={e.GetType().Name}");
                }
                finally
                {
                    DaoFactory.DisposeDao(artistCategoryDao);
                }
            }

            return model;
        }
        public ListResultModel<PerformanceModel> GetPerformances(PerformanceFilterRequest filter)
        {
            IPerformanceDao performanceDao = DaoFactory.CreatePerformanceDao();
            ListResultModel<PerformanceModel> model = null;
            if ((model = HandleAuthentication<ListResultModel<PerformanceModel>>()) == null)
            {
                model = new ListResultModel<PerformanceModel>();
                try
                {
                    IList<Performance> performances = performanceDao.GetFilteredPerformancesForExport(null, filter.StartDate, filter.EndDate, filter.ArtistIds, filter.VenueIds, filter.ArtistGroupIds, filter.ArtistCategoryIds, filter.Countries, false, filter.Moved);
                    model.Result = performances.Select(item => new PerformanceModel
                    {
                        Id = item.Id.Value,
                        Version = item.Version.Value,
                        StartDate = item.StartDate.Value,
                        EndDate = item.EndDate.Value,
                        FormerStartDate = item.FormerStartDate,
                        FormerEndDate = item.FormerEndDate,
                        Artist = new ArtistModel
                        {
                            Id = item.Artist.Id.Value,
                            FirstName = item.Artist.Firstname,
                            LastName = item.Artist.Lastname,
                            CountryCode = item.Artist.CountryCode,
                            ArtistGroup = ((item.Artist.ArtistGroupId != null) ? item.Artist.ArtistGroup.Name : null),
                            ArtistCategory = item.Artist.ArtistCategory.Name
                        },
                        Venue = new VenueModel
                        {
                            Id = item.Venue.Id.Value,
                            Name = item.Venue.Name
                        },
                        FormerVenue = ((item.FormerVenueId != null) ? new VenueModel
                        {
                            Id = item.FormerVenue.Id.Value,
                            Name = item.FormerVenue.Name
                        } : null)
                    }).ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine("GetPerformances: Error during processing. error: " + e.Message);
                    model.ErrorCode = (int)ErrorCode.UNKNOWN_ERROR;
                    model.Error = ("Error during processing the request. error: " + e.Message);
                }
                finally
                {
                    DaoFactory.DisposeDao(performanceDao);
                }
            }

            return model;
        }