示例#1
0
            private ConcertModel PopulateSingleConcertFromDbReader(SqlDataReader dbReader)
            {
                var concertPerformer = new PerformerModel
                {
                    PerformerId = dbReader.GetInt32(dbReader.GetOrdinal(@"performerId")),
                    FirstName   = dbReader.GetString(dbReader.GetOrdinal(@"performerFirstName")),
                    LastName    = dbReader.GetString(dbReader.GetOrdinal(@"performerLastName")),
                    ShortName   = dbReader.GetString(dbReader.GetOrdinal(@"performerShortName"))
                };

                var concertToReturn = new ConcertModel
                {
                    ConcertId      = dbReader.GetInt32(dbReader.GetOrdinal(@"concertId")),
                    ConcertDate    = dbReader.GetDateTime(dbReader.GetOrdinal(@"concertDate")),
                    ConcertName    = dbReader.GetString(dbReader.GetOrdinal(@"concertName")),
                    VenueId        = dbReader.GetInt32(dbReader.GetOrdinal(@"venueId")),
                    Description    = dbReader.GetString(dbReader.GetOrdinal(@"concertDescription")),
                    PerformerId    = dbReader.GetInt32(dbReader.GetOrdinal(@"concertPerformerId")),
                    PerformerModel = concertPerformer,
                    SaveToDbServer = (dbReader.IsDBNull(dbReader.GetOrdinal(@"saveToDatabase")))
                                         ? ((int)ServerTargetEnum.Primary)
                                         : ((ServerTargetEnum)dbReader.GetInt32(dbReader.GetOrdinal(@"saveToDatabase")))
                };

                return(concertToReturn);
            }
示例#2
0
            public PerformerModel GetArtistByName(String artistName)
            {
                PerformerModel artistToReturn = null;

                using (var dbConnection = WingtipTicketApp.CreateTenantConnectionDatabase1())
                {
                    try
                    {
                        dbConnection.Open();
                        var queryCommand = new SqlCommand(String.Format("Select Top(1) * From Performers Where ShortName='{0}'", artistName), dbConnection);

                        using (var reader = queryCommand.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                artistToReturn = PopulateSingleArtistFromDbReader(reader);
                            }
                        }
                    }
                    finally
                    {
                        dbConnection.Close();
                    }
                }

                return(artistToReturn);
            }
        private bool UpsertArtist(EventAdministrationViewModel viewModel, out PerformerModel artistFromDb)
        {
            // Add artist if it doesn't exist
            if (!string.IsNullOrWhiteSpace(viewModel.NewArtist))
            {
                artistFromDb = _artistRepository.GetArtistByName(viewModel.NewArtist.Trim());

                if (artistFromDb == null)
                {
                    artistFromDb = _artistRepository.AddNewArtist(viewModel.NewArtist);

                    if (artistFromDb == null)
                    {
                        DisplayMessage(String.Format("Failed to add new Artist '{0}'. Cannot Continue.", viewModel.NewArtist));
                        return(false);
                    }
                }
            }
            else
            {
                artistFromDb = _artistRepository.GetArtistById(viewModel.ArtistId);
            }

            return(true);
        }
示例#4
0
        public ActionResult AddPerformer(PerformerModel performerModel)
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context           = new QulixContext(connectionFactory);

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var performerService  = new PerformerService(uow, repositoryFactory);
                var performer         = performerService.CreatePerformer(performerModel.FirstName, performerModel.LastName, performerModel.PatronymicName);
                return(RedirectToAction("ViewPerformers", "Home"));
            }
        }
        private bool UpsertEvent(EventAdministrationViewModel viewModel, VenueModel venueModelForConcert, PerformerModel artistFromDb)
        {
            // Add event if it doesn't exist
            const ServerTargetEnum saveToShardDb = ServerTargetEnum.Primary;
            var eventDateTime = new DateTime(viewModel.Year, viewModel.Month, viewModel.Day, 20, 0, 0);

            if (_concertRepository.SaveNewConcert(viewModel.NewEvent, viewModel.Description, eventDateTime, saveToShardDb, venueModelForConcert.VenueId, artistFromDb.PerformerId) == null)
            {
                DisplayMessage(String.Format(" Failed to add new concert event. \'{0}\'", viewModel.NewEvent));
                return(false);
            }

            DisplayMessage(string.Format("Successfully added new event {0}.", viewModel.NewEvent));
            return(true);
        }
示例#6
0
 public frmPerformer(BusinessObjectServiceClient boServiceClient)
 {
     InitializeComponent();
     _performerModel = new PerformerModel(boServiceClient);
     InitControls();
 }