Example #1
0
        public override bool DelayPerformance(SessionToken token, Performance oldPerformance, Performance newPerformance)
        {
            if (!IsUserAuthenticated(token)
                || !IsPerformanceValid(oldPerformance)
                || !IsPerformanceValid(newPerformance)
                || Equals(oldPerformance, newPerformance))
            {
                return false;
            }

            Performance checkResult = null;
            PerformanceDao.SelectById(oldPerformance.DateTime,
                oldPerformance.Artist.ArtistId)
                .OnSuccess(response => checkResult = response.ResultObject);

            if (checkResult == null)
                return false;

            var insertStatus = DaoStatus.Failed;
            using (var scope = new TransactionScope())
            {
                var deleteStatus = PerformanceDao.Delete(oldPerformance).ResponseStatus;
                if (deleteStatus == DaoStatus.Successful)
                    insertStatus = PerformanceDao.Insert(newPerformance).ResponseStatus;
                if (insertStatus == DaoStatus.Successful)
                    scope.Complete();
            }
            return insertStatus == DaoStatus.Successful;
        }
Example #2
0
 public DaoResponse<Performance> Delete(Performance entity)
 {
     using (var connection = _dbCommProvider.CreateDbConnection())
     using (var command = _dbCommProvider.CreateDbCommand(connection, SqlQueries.DeletePerformance, CreatePerformanceParameter(entity)))
     {
         _dbCommProvider.ExecuteNonQuery(command);
     }
     return DaoResponse.QuerySuccessful(entity);
 }
Example #3
0
        private void InitializeData()
        {
            SaveCommand = new RelayCommand((() =>
            {
                if (CurrentVenueViewModel == null 
                || CurrentArtistViewModel == null 
                || string.IsNullOrEmpty(DateTimeViewModel.Hour))
                    return;

                var performance = new Performance
                {
                    DateTime = DateTimeViewModel.DateTime,
                    Artist = CurrentArtistViewModel.ToDomainObject<Artist>(),
                    Venue = CurrentVenueViewModel.ToDomainObject<Venue>()
                };
                _adminAccessBll.ModifyPerformance(BllAccessHandler.SessionToken, performance);
                Locator.PerformanceOverviewViewModel.Performances.Add(performance.ToViewModelObject<PerformanceViewModel>());
                ResetData();
                Locator.PerformanceOverviewViewModel.AddNotification(
                    performance.ToViewModelObject<PerformanceViewModel>(), (IsNew) ? NotificationType.Add : NotificationType.Modified);
                Messenger.Default.Send(new HideDialogMessage(Locator.PerformanceEditViewModel));
            }));
            CancelCommand = new RelayCommand((() =>
            {
                Messenger.Default.Send(new HideDialogMessage(Locator.PerformanceEditViewModel));
            }));

            DateTimeViewModel = DateTime.Now;
            for (var i = 14; i < 25; i++)
            {
                var hour = $"{i%24}:00";
                if (i == 24)
                    hour = $"0{hour}";
                Hours.Add(hour);
            }

            LoadData();
        }
Example #4
0
 public bool DelayPerformance(SessionToken token, Performance oldPerformance, Performance newPerformance) => AdminAccessDelegate.DelayPerformance(token, oldPerformance, newPerformance);
Example #5
0
 public bool ModifyPerformance(SessionToken token, Performance performance) => AdminAccessDelegate.ModifyPerformance(token, performance);
Example #6
0
 public bool RemovePerformance(SessionToken token, Performance performance) => AdminAccessDelegate.RemovePerformance(token, performance);
Example #7
0
        public override bool RemovePerformance(SessionToken token, Performance performance)
        {
            if (!IsUserAuthenticated(token) || !IsPerformanceValid(performance))
                return false;

            var result = PerformanceDao.SelectById(performance.DateTime, performance.Artist.ArtistId);
            if (result.ResponseStatus == DaoStatus.Successful)
                result = PerformanceDao.Delete(performance);

            return result.ResponseStatus == DaoStatus.Successful;
        }
Example #8
0
        public override bool ModifyPerformance(SessionToken token, Performance performance)
        {
            if (!IsUserAuthenticated(token) || !IsPerformanceValid(performance))
                return false;

            var result = PerformanceDao.SelectById(performance.DateTime, performance.Artist.ArtistId);
            if (result.ResponseStatus == DaoStatus.Successful)
            {
                if (IsPerformanceDateTimeDelayValid(result.ResultObject, performance))
                    result = PerformanceDao.Update(performance);
                else
                    result.ResponseStatus = DaoStatus.Failed;
            }
            else
            {
                if (IsDateTimeFormatValid(performance.DateTime))
                    result = PerformanceDao.Insert(performance);
                else
                    result.ResponseStatus = DaoStatus.Failed;
            }
            return result.ResponseStatus == DaoStatus.Successful;
        }
Example #9
0
        private void VerifyPerformanceValue(Performance entity)
        {
            if (entity.DateTime.Minute != 0 || entity.DateTime.Second != 0)
            {
                throw new InvalidOperationException("Invalid Date format: Only full hours allowed!");
            }

            var fromTime = entity.DateTime.AddHours(-1);
            var toTime = entity.DateTime.AddHours(1);

            var parameter = new Dictionary<string, QueryParameter>
            {
                {"?FromTime", new QueryParameter {ParameterValue = fromTime.ToString(Constants.CommonDateFormatFull)}},
                {"?ToTime", new QueryParameter {ParameterValue = toTime.ToString(Constants.CommonDateFormatFull)}},
                {"?ArtistId", new QueryParameter {ParameterValue = entity.Artist?.ArtistId}}
            };

            using (var connection = _dbCommProvider.CreateDbConnection())
            using (var command = _dbCommProvider.CreateDbCommand(connection, SqlQueries.SelectPerformanceBetweenHours, parameter))
            using (var dataReader = _dbCommProvider.ExecuteReader(command))
            {
                if (dataReader.Read())
                {
                    throw new InvalidOperationException("Invalid Date format: ArtistId already performing!");
                }
            }
        }
Example #10
0
 private Dictionary<string, QueryParameter> CreatePerformanceParameter(Performance performance)
 {
     return new Dictionary<string, QueryParameter>
     {
         {"?Date", new QueryParameter {ParameterValue = performance.DateTime.ToString(Constants.CommonDateFormatFull)}},
         {"?ArtistId", new QueryParameter {ParameterValue = performance.Artist.ArtistId}},
         {"?VenueId", new QueryParameter {ParameterValue = performance.Venue.VenueId}}
     };
 }
Example #11
0
        private Performance CreatePerformanceObject(IDataReader dataReader)
        {
            var performance = new Performance
            {
                DateTime = (DateTime)dataReader["Date"]
            };

            var artist = new Artist
            {
                ArtistId = _dbCommProvider.CastDbObject<int>(dataReader, "ArtistId"),
                Name =  _dbCommProvider.CastDbObject<string>(dataReader, "ArtistName"),
                EMail = _dbCommProvider.CastDbObject<string>(dataReader, "EMail"),
                PromoVideo = _dbCommProvider.CastDbObject<string>(dataReader, "PromoVideo"),
                Picture = new BlobData
                {
                    Path = _dbCommProvider.CastDbObject<string>(dataReader, "Picture")
                },
                Country = new Country
                {
                    Code = _dbCommProvider.CastDbObject<string>(dataReader, "CountryCode"),
                    Name = _dbCommProvider.CastDbObject<string>(dataReader, "CountryName")
                }
            };
            if (!_dbCommProvider.IsDbNull(dataReader, "CategoryId"))
            {
                artist.Category = new Category
                {
                    CategoryId = _dbCommProvider.CastDbObject<string>(dataReader, "CategoryId"),
                    Name = _dbCommProvider.CastDbObject<string>(dataReader, "CategoryName"),
                    Color = _dbCommProvider.CastDbObject<string>(dataReader, "CategoryColor")
                };
            }
            performance.Artist = artist;

            if (!_dbCommProvider.IsDbNull(dataReader, "VenueId"))
            {
                var venue = new Venue
                {
                    VenueId = _dbCommProvider.CastDbObject<string>(dataReader, "VenueId"),
                    Name = _dbCommProvider.CastDbObject<string>(dataReader, "VenueName"),
                    Location = new Location
                    {
                        LocationId = _dbCommProvider.CastDbObject<int>(dataReader, "LocationId"),
                        Name = _dbCommProvider.CastDbObject<string>(dataReader, "LocationName"),
                        Latitude = _dbCommProvider.CastDbObject<decimal>(dataReader, "Latitude"),
                        Longitude = _dbCommProvider.CastDbObject<decimal>(dataReader, "Longitude")
                    }
                };
                performance.Venue = venue;
            }
            return performance;
        }
Example #12
0
        public void TestInsertPerformanceDbAccess()
        {
            var dao = FactoryProvider.GetFactory<IDaoProviderFactory>(
                TestDbDaoAssemblyName,
                TestDbDaoNameSpace,
                TestDbDaoClassName).CreatePerformanceDao();
            using (var scope = new TransactionScope())
            {
                var performance = new Performance
                {
                    DateTime = new DateTime(2016, 7, 18, 21, 00, 00),
                    Artist = new Artist {ArtistId = 1},
                    Venue = new Venue{VenueId = "A2"}
                };
                dao.Insert(performance)
                    .OnFailure(response => Assert.Fail($"Insert does not work! {response.Exception}"));

                // do not commit changes; only for testing
                //scope.Complete();
            }
        }
Example #13
0
        public void TestInsertInvalidPerformanceDbAccess()
        {
            var dao = FactoryProvider.GetFactory<IDaoProviderFactory>(
                TestDbDaoAssemblyName,
                TestDbDaoNameSpace,
                TestDbDaoClassName).CreatePerformanceDao();
            using (var scope = new TransactionScope())
            {
                var performance = new Performance
                {
                    DateTime = new DateTime(2015, 11, 15, 23, 00, 00),
                    Artist = new Artist { ArtistId = 39 },
                    Venue = new Venue { VenueId = "A2" }
                };
                dao.Insert(performance)
                    .OnSuccess(response => Assert.Fail($"Insert worked although entry already exists! {response.DateTime}"));

                // do not commit changes; only for testing
                //scope.Complete();
            }
        }
 public static async Task<bool> ModifyPerformanceAsync(this IAdminAccessBll accessBll, SessionToken token, Performance performance)
 {
     var performanceWs = performance.ToWebSeriveObject<WS.Performance>();
     var tokenWs = token.ToWebSeriveObject<WS.SessionToken>();
     return await AdminAccessWs.ModifyPerformanceAsync(tokenWs, performanceWs);
 }
Example #15
0
 public DaoResponse<Performance> Update(Performance entity)
 {
     throw new System.NotImplementedException();
 }