Beispiel #1
0
        void OnTableCellSelected(Concert concert)
        {
            var detailView = new ListDetailController ((RectangleF)View.Frame);
            detailView.BindTo (concert);

            NavigationController.PushViewController (detailView, true);
        }
Beispiel #2
0
        // GET: MyConcerts/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Concert concert = db.Concerts.Find(id);

            if (concert == null)
            {
                return(HttpNotFound());
            }
            return(View(concert));
        }
        public IHttpActionResult DeleteConcert(long id)
        {
            Concert concert = db.Concerts.Find(id);

            if (concert == null)
            {
                return(NotFound());
            }

            db.Concerts.Remove(concert);
            db.SaveChanges();

            return(Ok(concert));
        }
Beispiel #4
0
        public IActionResult OnPostAsyncCreateConcert()
        {
            string Artist      = Request.Form["ArtistEntered"];
            string Description = Request.Form["DescriptionEntered"];
            string Image       = "";

            if (Request.Form.Files.Count > 0)
            {
                var file = Request.Form.Files[0];
                Image = file.FileName;
                BlobStorageManager.Upload(Image, file.OpenReadStream());
            }

            string Venue = Request.Form["VenueEntered"];
            string Date = Request.Form["DateEntered"];
            string StartTime = Request.Form["StartTimeEntered"];
            string EndTime = Request.Form["EndTimeEntered"];
            int    Year = 0001, Month = 01, StartDay = 01, EndDay = 01;
            int    StartHour = 0, StartMinute = 0, EndHour = 0, EndMinute = 0;

            if (Date != "")
            {
                Year     = int.Parse(Date.Substring(0, 4));
                Month    = int.Parse(Date.Substring(5, 2));
                StartDay = EndDay = int.Parse(Date.Substring(8, 2));
            }
            if (StartTime != "")
            {
                StartHour   = int.Parse(StartTime.Substring(0, 2));
                StartMinute = int.Parse(StartTime.Substring(3, 2));
            }
            if (EndTime != "")
            {
                EndHour   = int.Parse(EndTime.Substring(0, 2));
                EndMinute = int.Parse(EndTime.Substring(3, 2));
            }
            if (StartHour > EndHour || ((StartHour == EndHour) && (StartMinute > EndMinute)))
            {
                EndDay++;
            }

            DateTime Start      = new DateTime(Year, Month, StartDay, StartHour, StartMinute, 0);
            DateTime End        = new DateTime(Year, Month, EndDay, EndHour, EndMinute, 0);
            Concert  NewConcert = new Concert(Start, End, Artist, Description, Image, DataAccess);


            FestivalManager.Calendar.AddConcert(NewConcert, Venue);
            return(RedirectToPage("./Calendar"));
        }
Beispiel #5
0
        public void DeleteConcert_DoesNotDeleteANonExistingConcert()
        {
            //Arrange
            Calendar calendar    = GetCalendarWithTwoConcertsAndTwoVenues();
            int      expected    = 2;
            var      mockContext = new Mock <NorthernWinterBeatConcertContext>();
            Concert  concert     = new Concert(mockContext.Object);

            //Act
            calendar.DeleteConcert(concert);
            int result = calendar.GetConcerts().Count;

            //Assert
            Assert.Equal(expected, result);
        }
Beispiel #6
0
        // GET: Concerts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Concert concert = db.Concerts.Find(id);

            if (concert == null)
            {
                return(HttpNotFound());
            }
            ViewBag.HostID = new SelectList(db.Hosts, "Id", "VenueName", concert.HostID);
            return(View(concert));
        }
Beispiel #7
0
        public async Task <Concert> InsertConcertAsync(Concert newConcert, List <Band> bands)
        {
            bands.ForEach(b =>
            {
                var concertBand = new ConcertBand {
                    Band = _context.Bands.Find(b.Id), Concert = newConcert
                };
                newConcert.ConcertBands.Add(concertBand);
            });

            _context.Concerts.Add(newConcert);
            await _context.SaveChangesAsync();

            return(newConcert);
        }
Beispiel #8
0
        private Concert GetConcertAtMaxCapacity()
        {
            var   mock  = new Mock <IDataAccess>();
            Venue venue = new Venue(mock.Object);

            venue.Capacity = 1;

            Concert concert = new Concert(mock.Object);

            concert.Venue = venue;

            concert.Bookings.Add(new Booking(mock.Object));

            return(concert);
        }
Beispiel #9
0
        public void Repository_AddItem_SetsIdCorrectly()
        {
            // Arrange
            var repository = new ConcertRepository();
            var concert    = new Concert()
            {
                Artist = "New Artist",
            };

            // Act
            var sut = repository.Insert(concert);

            // Assert
            sut.Should().Be(5);
        }
 private void PopulateFeaturedArtists(Concert concert)
 {
     FeaturedArtists.Clear();
     foreach (var song in SongList)
     {
         foreach (var artist in song.Artists)
         {
             if (FeaturedArtists.Contains(artist))
             {
                 continue;
             }
             FeaturedArtists.Add(artist);
         }
     }
 }
Beispiel #11
0
        public async Task <ActionResult> Edit(int id, Concert concert)
        {
            if (ModelState.IsValid)
            {
                // TODO: Add update logic here
                var userId = User.Identity.GetUserId();
                concert.ApplicationId = userId;
                concert = await GetLatNLngAsync(concert);

                db.Entry(concert).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #12
0
        public async Task PutConcertReturnsBadRequestResultIdTest()
        {
            // Arrange
            int     testId     = 2;
            Concert concert    = GetTestConcerts()[0];
            var     mockRepo   = new Mock <IConcertRepository>();
            var     mockLogger = new Mock <ILogger <ConcertsController> >();
            var     controller = new ConcertsController(mockRepo.Object, mockLogger.Object);

            // Act
            var result = await controller.PutConcert(testId, concert);

            // Assert
            Assert.IsType <BadRequestResult>(result);
        }
Beispiel #13
0
        public void PostConcert_ConcertIsNull_ThrowsException()
        {
            _concert = null;

            try
            {
                _controller.CreateConcert(false, _concert);
            }
            catch (ClientRequestException ex)
            {
                Assert.AreEqual(HttpStatusCode.BadRequest, ex.StatusCode);
                Assert.AreEqual("Failed to parse Concert.", ex.Message);
                throw;
            }
        }
Beispiel #14
0
        private void ConcertOuting()
        {
            Concert concert = new Concert();

            concert.TypeOfEvent = "Amusement Park";
            Console.WriteLine("How many people attended this event?");
            concert.NumberOfPeople = int.Parse(Console.ReadLine());
            Console.WriteLine("What was the total event cost?");
            concert.EventCost     = decimal.Parse(Console.ReadLine());
            concert.CostPerPerson = concert.EventCost / concert.NumberOfPeople;
            Console.WriteLine($"This event cost ${concert.CostPerPerson}");
            Console.WriteLine("When was this event?");
            concert.DateOfEvent = DateTime.Parse(Console.ReadLine());
            _outing.AddToOutingList(concert);
        }
Beispiel #15
0
        public async Task UpdateConcertAsync(int concertId, Concert updatedConcert, List <Band> bands)
        {
            //Lekérdezzük a módosítandó koncertet, ki szeretnénk törölni belőle az együtteseket
            var oldConcert = await _context.Concerts
                             .Include(c => c.ConcertBands)
                             .SingleOrDefaultAsync(c => c.Id == concertId);

            if (oldConcert != null) //Ha megvan
            {
                //Lekérdezzük a hozzá tartozó ConcertBandeket
                var concertBands = oldConcert.ConcertBands.Where(cb => cb.ConcertId == concertId).ToList();
                foreach (var concertBand in concertBands)
                {
                    //És kitöröljük őket
                    oldConcert.ConcertBands.Remove(concertBand);
                }

                await _context.SaveChangesAsync(); //Elmentjük a törlést

                //Leállítjuk a koncert követését, enélkül nem lehetne a koncert objektumra frissíteni
                _context.Entry(oldConcert).State = EntityState.Detached;
            }

            updatedConcert.Id = concertId;
            bands.ForEach(b =>
            {
                //Hozzáadjuk az új koncerthez az összes együttes ConcertBand objektumát
                var concertBand = new ConcertBand {
                    Band = _context.Bands.Find(b.Id), Concert = updatedConcert
                };
                updatedConcert.ConcertBands.Add(concertBand);
            });

            var entry = _context.Concerts.Attach(updatedConcert);

            entry.State = EntityState.Modified; //Attach nem teszi magától Modified-ba
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (await _context.Concerts.SingleOrDefaultAsync(c => c.Id == concertId) == null)
                {
                    throw new EntityNotFoundException($"Nem található Id={concertId} koncert!");
                }
            }
        }
Beispiel #16
0
    private static async Task <(Concert, Track)> GetConcertAndTrackAsync(SpannerSampleDbContext context)
    {
        var singer = new Singer
        {
            SingerId  = Guid.NewGuid(),
            FirstName = "Alice",
            LastName  = "Jameson",
        };
        await context.Singers.AddAsync(singer);

        var album = new Album
        {
            AlbumId  = Guid.NewGuid(),
            Title    = "Rainforest",
            SingerId = singer.SingerId,
        };
        await context.Albums.AddAsync(album);

        var track = new Track
        {
            AlbumId = album.AlbumId,
            TrackId = 1,
            Title   = "Butterflies",
        };
        await context.Tracks.AddAsync(track);

        if (await context.Venues.FindAsync("CON") == null)
        {
            await context.Venues.AddAsync(new Venue
            {
                Code   = "CON",
                Name   = "Concert Hall",
                Active = true,
            });
        }
        var concert = new Concert
        {
            VenueCode = "CON",
            SingerId  = singer.SingerId,
            StartTime = new DateTime(2021, 1, 27, 18, 0, 0, DateTimeKind.Utc),
            Title     = "Alice Jameson - LIVE in Concert Hall",
        };
        await context.AddAsync(concert);

        await context.SaveChangesAsync();

        return(concert, track);
    }
Beispiel #17
0
        public ActionResult Delete(int id, Concert concert)
        {
            try
            {
                // TODO: Add delete logic here
                var foundConcert = db.Concerts.Find(id);
                db.Concerts.Remove(foundConcert);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Concert = await _context.Concert
                      .Include(c => c.PerformingBand).FirstOrDefaultAsync(m => m.Id == id);

            if (Concert == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #19
0
        public void Repository_AddItem_IsSuccessfullySaved()
        {
            // Arrange
            var repository = new ConcertRepository();
            var concert    = new Concert()
            {
                Artist = "New Artist",
            };
            var originalCount = repository.Count();

            // Act
            var result = repository.Insert(concert);

            // Assert
            repository.Count().Should().Be(originalCount + 1);
        }
        private void CreateNewConcert(object sender, EventArgs e)
        {
            Concert newConcert = null;

            using (var concertDialog = new ConcertCreationDialog())
            {
                var dialogResult = concertDialog.ShowDialog(this);
                if (dialogResult == DialogResult.Cancel)
                {
                    return;
                }
                newConcert = concertDialog.NewConcert;
            }

            _model.CreateConcert(newConcert);
        }
        public async Task <IActionResult> PostConcert([FromBody] Concert concert)
        {
            _logger.LogInformation("-> requested POST /concerts");
            if (!ModelState.IsValid)
            {
                _logger.LogError("-> POST /concerts model is not valid");
                _logger.LogInformation("-> POST /concerts returned BadRequest");
                return(BadRequest(ModelState));
            }

            concert = _repo.AddConcert(concert);
            await _repo.SaveChanges();

            _logger.LogInformation("-> POST /concerts returned Created with id = {id}", concert.Id);
            return(CreatedAtAction("GetConcert", new { id = concert.Id }, concert));
        }
        public void UpdateConcertWithMusician(String concertName, String musicianName)
        {
            Concert concertToUpdate = GetConcert(concertName);

            Musician musicianToUpdate = GetConcertHasMusician(concertToUpdate, musicianName);

            if (musicianToUpdate == null)
            {
                musicianToUpdate = musicianRepository.GetMusician(musicianName);
                concertToUpdate.musicians.Add(musicianToUpdate);
            }
            else
            {
                concertToUpdate.musicians.Remove(musicianToUpdate);
            }
        }
Beispiel #23
0
        public void MakeBooking_CannotMakeBookingWhenParticipantCannotMakeBooking()
        {
            //Arrange
            Concert concert             = GetConcertAtMaxCapacity();
            Booking expected            = null;
            var     mock                = new Mock <Participant>();
            var     mockFestivalManager = new Mock <IFestivalManager>();

            mock.Setup(p => p.CanMakeBookingAt(concert, mockFestivalManager.Object)).Returns(false); //Defining other argument in if-statement as always false

            //Act
            Booking result = concert.MakeBooking(mock.Object, mockFestivalManager.Object);

            //Assert
            Assert.Equal(expected, result);
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Concert = await _context.Concert.FindAsync(id);

            if (Concert != null)
            {
                _context.Concert.Remove(Concert);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #25
0
        public async Task <ActionResult <Concert> > CreateConcertAsync(Guid appUserId, [FromBody] Concert concert)
        {
            Guid id = Guid.NewGuid();

            Ids.Add(id);

            Concert newConcert = new Concert
            {
                Id        = id,
                AppUserId = appUserId,
                Name      = "Új"
            };

            concerts.Add(newConcert);

            return(CreatedAtAction(nameof(GetConcertByIdAsync), new { id = newConcert.Id }, newConcert));
        }
Beispiel #26
0
        public ActionResult Concert_Details(Guid?Id = null)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Concert concert = db.Concerts.AsParallel().Select(x => new Concert {
                Id = x.Id, Date = x.Date, Address = x.Address, Description = x.Description
            }).Where(x => x.Id == Id).FirstOrDefault();

            if (concert == null)
            {
                return(HttpNotFound());
            }

            return(View(concert));
        }
        public IActionResult OnPostNewBooking(int id)
        {
            var claimTicketID = HttpContext.User.Claims.Where(c => c.Type == "TicketID").Select(t => t.Value).First();

            Concert     concert = FestivalManager.Calendar.GetConcert(id);
            Participant p       = FestivalManager.GetParticipants().Where(p => p.Ticket?.TicketNumber == claimTicketID).First();

            List <Concert> overlappedConcerts = p.GetParticipantBookings(FestivalManager).Select(b => b.Concert).Where(c => concert.Start <c.End && concert.End> c.Start).ToList();

            foreach (Concert overlap in overlappedConcerts)
            {
                overlap.RemoveBooking(p);
            }

            concert.MakeBooking(p, FestivalManager);
            return(RedirectToPage("./ParticipantArtist", new { id = id }));
        }
Beispiel #28
0
        public async Task <ActionResult> Create(Concert concert)
        {
            try
            {
                var userId = User.Identity.GetUserId();
                concert.ApplicationId = userId;
                concert = await GetLatNLngAsync(concert);

                db.Concerts.Add(concert);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #29
0
        public async Task ProblemJson_405_MethodNotAllowed_Test()
        {
            //Arrange
            var concert = new Concert
            {
                ConcertId = Guid.NewGuid(),
                Name      = "Best Kept Secret Festival 2019"
            };
            var request = TestExtensions.GetJsonRequest(concert, "PUT", "/core/v1/concerts");
            //Act
            var response = await fixture._httpClient.SendAsync(request);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.MethodNotAllowed);
            response.Content.Headers.ContentLength.Should().BeGreaterThan(0);
            response.ShouldBeProblemJson();
        }
        public static void ValidateUpdateConcert(Concert concert)
        {
            if (concert == null)
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "Failed to parse Concert.");
            }

            if (concert.Id == 0)
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "Concert ID is required.");
            }

            if (!concert.ValidateConcert())
            {
                throw new ClientRequestException(HttpStatusCode.BadRequest, "Concert or one of its properties is null or incorrect.");
            }
        }
Beispiel #31
0
        public void MakeBooking_CanMakeBookingWhenNotAtMaxCapacity()
        {
            //Arrange
            Concert concert             = GetConcertWithSpaceForTwo();
            var     mock                = new Mock <Participant>();
            var     mockFestivalManager = new Mock <IFestivalManager>();

            mock.Setup(p => p.CanMakeBookingAt(concert, mockFestivalManager.Object)).Returns(true); //Defining other argument in if-statement as always true
            var expected = (mock.Object, concert);

            //Act
            Booking resultBooking = concert.MakeBooking(mock.Object, mockFestivalManager.Object);
            var     result        = (resultBooking?.Participant, resultBooking?.Concert);

            //Assert
            Assert.Equal(expected, result);
        }
 protected override void ExecuteInsertVenueCommand(string[] commandWords)
 {
     switch (commandWords[2])
     {
         case "opera":
             var opera = new Opera(commandWords[3], commandWords[4], int.Parse(commandWords[5]));
             this.Venues.Add(opera);
             break;
         case "sports_hall":
             var sportsHall = new Sport(commandWords[3], commandWords[4], int.Parse(commandWords[5]));
             this.Venues.Add(sportsHall);
             break;
         case "concert_hall":
             var concertHall = new Concert(commandWords[3], commandWords[4], int.Parse(commandWords[5]));
             this.Venues.Add(concertHall);
             break;
         default:
             base.ExecuteInsertVenueCommand(commandWords);
             break;
     }
 }
        public ActionResult AddConcert(ConcertInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var artistId = this.users.UserIdByUsername(this.User.Identity.GetName());

            var concert = new Concert()
            {
                Date = model.Date,
                City = model.City,
                ArtistId = artistId
            };

            this.concerts.AddConcert(concert);

            this.TempData["Notification"] = "You added concert successfully!";
            return this.RedirectToAction("Index", "Home", new { area = string.Empty });
        }
 protected override void ExecuteInsertPerformanceCommand(string[] commandWords)
 {
     var venue = this.GetVenue(commandWords[5]);
     switch (commandWords[2])
     {
         case "movie":
             var movie = new Movie(
                 commandWords[3],
                 decimal.Parse(commandWords[4]),
                 venue,
                 DateTime.Parse(commandWords[6] + " " + commandWords[7]));
             this.Performances.Add(movie);
             break;
         case "theatre":
             var theatre = new Theatre(
                 commandWords[3],
                 decimal.Parse(commandWords[4]),
                 venue,
                 DateTime.Parse(commandWords[6] + " " + commandWords[7]));
             this.Performances.Add(theatre);
             break;
         case "concert":
             var concert = new Concert(
                 commandWords[3],
                 decimal.Parse(commandWords[4]),
                 venue,
                 DateTime.Parse(commandWords[6] + " " + commandWords[7]));
             this.Performances.Add(concert);
             break;
         default:
             break;
     }
 }
 protected override void ExecuteInsertPerformanceCommand(string[] commandWords)
 {
     string venueName = commandWords[5];
     DateTime dateTime = DateTime.Parse(commandWords[6] + " " + commandWords[7]);
     string name = commandWords[3];
     decimal price = decimal.Parse(commandWords[4]);
     var venue = this.GetVenue(venueName);
     switch (commandWords[2])
     {
         case "theatre":
             var theatre = new Theatre(name, price, venue, dateTime);
             this.Performances.Add(theatre);
             break;
         case "concert":
             var concert = new Concert(name, price, venue, dateTime);
             this.Performances.Add(concert);
             break;
         default:
             base.ExecuteInsertPerformanceCommand(commandWords);
             break;
     }
 }